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.



18
19
20
21
22
# File 'lib/view_model/migration.rb', line 18

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

Instance Method Details

#build!Object



24
25
26
27
28
29
# File 'lib/view_model/migration.rb', line 24

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