Class: Sortiri::ActiveRecord::Column
- Inherits:
-
Object
- Object
- Sortiri::ActiveRecord::Column
- Defined in:
- lib/sortiri/active_record/column.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#association_name ⇒ Object
readonly
Returns the value of attribute association_name.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name:, model:, association_name: nil) ⇒ Column
constructor
A new instance of Column.
- #matches_with?(column_object) ⇒ Boolean
- #name_with_table_name ⇒ Object
- #table_name ⇒ Object
Constructor Details
#initialize(name:, model:, association_name: nil) ⇒ Column
Returns a new instance of Column.
8 9 10 11 12 |
# File 'lib/sortiri/active_record/column.rb', line 8 def initialize(name:, model:, association_name: nil) @name = name.to_s @model = model @association_name = association_name end |
Instance Attribute Details
#association_name ⇒ Object (readonly)
Returns the value of attribute association_name.
6 7 8 |
# File 'lib/sortiri/active_record/column.rb', line 6 def association_name @association_name end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/sortiri/active_record/column.rb', line 6 def name @name end |
Instance Method Details
#matches_with?(column_object) ⇒ Boolean
18 19 20 21 22 |
# File 'lib/sortiri/active_record/column.rb', line 18 def matches_with?(column_object) return false unless column_object.is_a?(Sortiri::Column) name == column_object.name && association_name.to_s == column_object.association.to_s end |
#name_with_table_name ⇒ Object
14 15 16 |
# File 'lib/sortiri/active_record/column.rb', line 14 def name_with_table_name [table_name, name].join('.') end |
#table_name ⇒ Object
24 25 26 |
# File 'lib/sortiri/active_record/column.rb', line 24 def table_name @model.table_name end |