Class: DataMigrations::Table
- Inherits:
-
Object
- Object
- DataMigrations::Table
- Defined in:
- lib/data_migrations/table.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #column(name) ⇒ Object
- #column_names ⇒ Object
- #columns ⇒ Object
-
#initialize(name) ⇒ Table
constructor
A new instance of Table.
- #quoted_name ⇒ Object
- #raise_column_not_found(name) ⇒ Object
Constructor Details
#initialize(name) ⇒ Table
Returns a new instance of Table.
7 8 9 |
# File 'lib/data_migrations/table.rb', line 7 def initialize(name) @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/data_migrations/table.rb', line 5 def name @name end |
Instance Method Details
#column(name) ⇒ Object
19 20 21 |
# File 'lib/data_migrations/table.rb', line 19 def column(name) columns.detect { |column| column.name.to_s == name.to_s } || raise_column_not_found(name) end |
#column_names ⇒ Object
15 16 17 |
# File 'lib/data_migrations/table.rb', line 15 def column_names columns.map(&:name) end |
#columns ⇒ Object
11 12 13 |
# File 'lib/data_migrations/table.rb', line 11 def columns connection.columns(name) end |
#quoted_name ⇒ Object
23 24 25 |
# File 'lib/data_migrations/table.rb', line 23 def quoted_name connection.quote_table_name(name) end |
#raise_column_not_found(name) ⇒ Object
27 28 29 |
# File 'lib/data_migrations/table.rb', line 27 def raise_column_not_found(name) raise "could not find column #{name} on #{self.name}" end |