Class: Hecks::Adapters::SQLDatabase::Table
- Inherits:
-
Object
- Object
- Hecks::Adapters::SQLDatabase::Table
- Defined in:
- lib/table.rb
Instance Attribute Summary collapse
-
#columns ⇒ Object
Returns the value of attribute columns.
Class Method Summary collapse
Instance Method Summary collapse
- #foreign_key_columns ⇒ Object
-
#initialize(name:, columns:) ⇒ Table
constructor
A new instance of Table.
- #join_table_columns ⇒ Object
- #name ⇒ Object
- #to_foreign_key ⇒ Object
Constructor Details
#initialize(name:, columns:) ⇒ Table
Returns a new instance of Table.
18 19 20 21 |
# File 'lib/table.rb', line 18 def initialize(name:, columns:) @name = name @columns = columns end |
Instance Attribute Details
#columns ⇒ Object
Returns the value of attribute columns.
5 6 7 |
# File 'lib/table.rb', line 5 def columns @columns end |
Class Method Details
Instance Method Details
#foreign_key_columns ⇒ Object
31 32 33 |
# File 'lib/table.rb', line 31 def foreign_key_columns columns.select(&:reference?) end |
#join_table_columns ⇒ Object
27 28 29 |
# File 'lib/table.rb', line 27 def join_table_columns columns.select(&:list?) end |
#name ⇒ Object
35 36 37 |
# File 'lib/table.rb', line 35 def name @name.pluralize.underscore end |
#to_foreign_key ⇒ Object
23 24 25 |
# File 'lib/table.rb', line 23 def to_foreign_key (name.singularize + '_id').to_sym end |