class ViewModel::Migration::Builder
Tiny DSL for defining migration classes
def build!
def build! migration = Class.new(@superclass) migration.define_method(:up, &@up_block) if @up_block migration.define_method(:down, &@down_block) if @down_block migration end
def check_signature!(block)
def check_signature!(block) unless block.arity == 2 raise RuntimeError.new('Illegal signature for migration method, must be (view, references)') end end
def down(&block)
def down(&block) check_signature!(block) @down_block = block end
def initialize(superclass = ViewModel::Migration)
def initialize(superclass = ViewModel::Migration) @superclass = superclass @up_block = nil @down_block = nil end
def up(&block)
def up(&block) check_signature!(block) @up_block = block end