Class: ConventionalModels::Table
- Inherits:
-
Object
- Object
- ConventionalModels::Table
- Defined in:
- lib/conventional_models/table.rb
Instance Attribute Summary collapse
-
#belongs_to_names ⇒ Object
Returns the value of attribute belongs_to_names.
-
#class_name ⇒ Object
Returns the value of attribute class_name.
-
#columns ⇒ Object
Returns the value of attribute columns.
-
#lines ⇒ Object
Returns the value of attribute lines.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #code ⇒ Object
- #conventional_name? ⇒ Boolean
-
#initialize(name, columns, conventions) ⇒ Table
constructor
A new instance of Table.
Constructor Details
#initialize(name, columns, conventions) ⇒ Table
Returns a new instance of Table.
5 6 7 8 9 10 11 12 13 |
# File 'lib/conventional_models/table.rb', line 5 def initialize(name, columns, conventions) @name = name @columns = columns @lines = [] @belongs_to_names = [] @config = conventions apply_conventions end |
Instance Attribute Details
#belongs_to_names ⇒ Object
Returns the value of attribute belongs_to_names.
3 4 5 |
# File 'lib/conventional_models/table.rb', line 3 def belongs_to_names @belongs_to_names end |
#class_name ⇒ Object
Returns the value of attribute class_name.
3 4 5 |
# File 'lib/conventional_models/table.rb', line 3 def class_name @class_name end |
#columns ⇒ Object
Returns the value of attribute columns.
3 4 5 |
# File 'lib/conventional_models/table.rb', line 3 def columns @columns end |
#lines ⇒ Object
Returns the value of attribute lines.
3 4 5 |
# File 'lib/conventional_models/table.rb', line 3 def lines @lines end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/conventional_models/table.rb', line 3 def name @name end |
Instance Method Details
#==(other) ⇒ Object
15 16 17 |
# File 'lib/conventional_models/table.rb', line 15 def ==(other) @name == other.name end |
#code ⇒ Object
19 20 21 |
# File 'lib/conventional_models/table.rb', line 19 def code "class ::#{@class_name} < #{@config.base_class}\n#{@lines.map{|l| " #{l}"}.join("\n")}\nend" end |
#conventional_name? ⇒ Boolean
23 24 25 |
# File 'lib/conventional_models/table.rb', line 23 def conventional_name? @name.tableize == @name end |