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.
50 51 52 53 54 55 56 |
# File 'lib/schema_plus/core/schema_dump.rb', line 50 def initialize(*args) super self.columns ||= [] self.indexes ||= [] self.statements ||= [] self.trailer ||= [] end |
Instance Attribute Details
#alt ⇒ Object
Returns the value of attribute alt
48 49 50 |
# File 'lib/schema_plus/core/schema_dump.rb', line 48 def alt @alt end |
#columns ⇒ Object
Returns the value of attribute columns
48 49 50 |
# File 'lib/schema_plus/core/schema_dump.rb', line 48 def columns @columns end |
#indexes ⇒ Object
Returns the value of attribute indexes
48 49 50 |
# File 'lib/schema_plus/core/schema_dump.rb', line 48 def indexes @indexes end |
#name ⇒ Object
Returns the value of attribute name
48 49 50 |
# File 'lib/schema_plus/core/schema_dump.rb', line 48 def name @name end |
#options ⇒ Object
Returns the value of attribute options
48 49 50 |
# File 'lib/schema_plus/core/schema_dump.rb', line 48 def end |
#pname ⇒ Object
Returns the value of attribute pname
48 49 50 |
# File 'lib/schema_plus/core/schema_dump.rb', line 48 def pname @pname end |
#statements ⇒ Object
Returns the value of attribute statements
48 49 50 |
# File 'lib/schema_plus/core/schema_dump.rb', line 48 def statements @statements end |
#trailer ⇒ Object
Returns the value of attribute trailer
48 49 50 |
# File 'lib/schema_plus/core/schema_dump.rb', line 48 def trailer @trailer end |
Instance Method Details
#assemble(stream) ⇒ Object
58 59 60 61 62 63 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 |
# File 'lib/schema_plus/core/schema_dump.rb', line 58 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 |