Class: Table
- Inherits:
-
Object
- Object
- Table
- Defined in:
- lib/infold/table.rb
Defined Under Namespace
Classes: Column
Instance Attribute Summary collapse
-
#columns ⇒ Object
Returns the value of attribute columns.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #add_columns(name, type) ⇒ Object
- #datetime_columns ⇒ Object
-
#initialize(name) ⇒ Table
constructor
A new instance of Table.
- #model_name ⇒ Object
Constructor Details
#initialize(name) ⇒ Table
Returns a new instance of Table.
8 9 10 11 |
# File 'lib/infold/table.rb', line 8 def initialize(name) self.name = name self.columns = [] end |
Instance Attribute Details
#columns ⇒ Object
Returns the value of attribute columns.
3 4 5 |
# File 'lib/infold/table.rb', line 3 def columns @columns end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/infold/table.rb', line 3 def name @name end |
Instance Method Details
#add_columns(name, type) ⇒ Object
17 18 19 |
# File 'lib/infold/table.rb', line 17 def add_columns(name, type) self.columns << Column.new(name, type) end |
#datetime_columns ⇒ Object
21 22 23 24 |
# File 'lib/infold/table.rb', line 21 def datetime_columns _columns = columns.select{ |c| c.type == 'datetime' && !%w(created_at updated_at).include?(c.name) } _columns.map(&:name) end |
#model_name ⇒ Object
13 14 15 |
# File 'lib/infold/table.rb', line 13 def model_name name.singularize.camelize end |