Class: ViewModel::Migration::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/view_model/migration.rb

Overview

Tiny DSL for defining migration classes

Instance Method Summary collapse

Constructor Details

#initialize(superclass = ViewModel::Migration) ⇒ Builder

Returns a new instance of Builder.



28
29
30
31
32
# File 'lib/view_model/migration.rb', line 28

def initialize(superclass = ViewModel::Migration)
  @superclass = superclass
  @up_block = nil
  @down_block = nil
end

Instance Method Details

#build!Object



34
35
36
37
38
39
# File 'lib/view_model/migration.rb', line 34

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