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, rails_version:) ⇒ MigrationDumper

Returns a new instance of MigrationDumper.



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

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

Instance Method Details

#dump_to(f) ⇒ Object



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

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

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

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