Class: SchemaPlus::Core::SchemaDump::Table
- Inherits:
-
Struct
- Object
- Struct
- SchemaPlus::Core::SchemaDump::Table
- Defined in:
- lib/schema_plus/core/schema_dump.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#alt ⇒ Object
Returns the value of attribute alt.
-
#columns ⇒ Object
Returns the value of attribute columns.
-
#indexes ⇒ Object
Returns the value of attribute indexes.
-
#name ⇒ Object
Returns the value of attribute name.
-
#options ⇒ Object
Returns the value of attribute options.
-
#pname ⇒ Object
Returns the value of attribute pname.
-
#statements ⇒ Object
Returns the value of attribute statements.
-
#trailer ⇒ Object
Returns the value of attribute trailer.
Instance Method Summary collapse
- #assemble(stream) ⇒ Object
-
#initialize(*args) ⇒ Table
constructor
A new instance of Table.
Constructor Details
#initialize(*args) ⇒ Table
Returns a new instance of Table.
56 57 58 59 60 61 62 |
# File 'lib/schema_plus/core/schema_dump.rb', line 56 def initialize(*args) super self.columns ||= [] self.indexes ||= [] self.statements ||= [] self.trailer ||= [] end |
Instance Attribute Details
#alt ⇒ Object
Returns the value of attribute alt
54 55 56 |
# File 'lib/schema_plus/core/schema_dump.rb', line 54 def alt @alt end |
#columns ⇒ Object
Returns the value of attribute columns
54 55 56 |
# File 'lib/schema_plus/core/schema_dump.rb', line 54 def columns @columns end |
#indexes ⇒ Object
Returns the value of attribute indexes
54 55 56 |
# File 'lib/schema_plus/core/schema_dump.rb', line 54 def indexes @indexes end |
#name ⇒ Object
Returns the value of attribute name
54 55 56 |
# File 'lib/schema_plus/core/schema_dump.rb', line 54 def name @name end |
#options ⇒ Object
Returns the value of attribute options
54 55 56 |
# File 'lib/schema_plus/core/schema_dump.rb', line 54 def end |
#pname ⇒ Object
Returns the value of attribute pname
54 55 56 |
# File 'lib/schema_plus/core/schema_dump.rb', line 54 def pname @pname end |
#statements ⇒ Object
Returns the value of attribute statements
54 55 56 |
# File 'lib/schema_plus/core/schema_dump.rb', line 54 def statements @statements end |
#trailer ⇒ Object
Returns the value of attribute trailer
54 55 56 |
# File 'lib/schema_plus/core/schema_dump.rb', line 54 def trailer @trailer end |
Instance Method Details
#assemble(stream) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/schema_plus/core/schema_dump.rb', line 64 def assemble(stream) if pname.nil? stream.puts alt stream.puts "" return end stream.write " create_table #{pname.inspect}" stream.write ", #{options}" unless .blank? stream.puts " do |t|" typelen = columns.map{|col| col.type.length}.max namelen = columns.map{|col| col.name.length}.max indexes columns.each do |column| stream.write " " column.assemble(stream, typelen, namelen) stream.puts "" end stream.puts "" unless indexes.empty? indexes.each do |index| stream.write " t.index " index.assemble(stream) 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 |