Class: SchemaMonkey::ActiveRecord::SchemaDumper::Dump::Table

Inherits:
Object
  • Object
show all
Defined in:
lib/schema_monkey/active_record/schema_dumper.rb

Defined Under Namespace

Classes: Column

Instance Method Summary collapse

Instance Method Details

#assemble(stream) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/schema_monkey/active_record/schema_dumper.rb', line 53

def assemble(stream)
  stream.write "  create_table #{pname.inspect}"
  stream.write ", #{options}" unless options.blank?
  stream.puts " do |t|"
  typelen = @columns.map{|col| col.type.length}.max
  namelen = @columns.map{|col| col.name.length}.max
  @columns.each do |column|
    stream.write "    "
    column.assemble(stream, typelen, namelen)
    stream.puts ""
  end
  statements.each do |statement|
    stream.puts "    #{statement}"
  end
  stream.puts "  end"
  trailer.each do |statement|
    stream.puts "  #{statement}"
  end
  stream.puts ""
end