Class: Unschema::MigrationDumper

Inherits:
Object
  • Object
show all
Defined in:
lib/unschema/migration_dumper.rb

Instance Method Summary collapse

Constructor Details

#initialize(table_name, calls) ⇒ MigrationDumper

Returns a new instance of MigrationDumper.



3
4
5
6
# File 'lib/unschema/migration_dumper.rb', line 3

def initialize(table_name, calls)
  @table_name = table_name
  @calls      = calls
end

Instance Method Details

#dump_to(f) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/unschema/migration_dumper.rb', line 8

def dump_to(f)
  f << "class Create#{table_name_camelcased} < ActiveRecord::Migration\n"
  f << "  def change\n"

  @calls.each do |call|
    f << dump_call(call)
  end

  f << "  end\n"
  f << "end\n"
end