Class: PassiveRecord::Associations::BelongsToAssociation
- Inherits:
-
Struct
- Object
- Struct
- PassiveRecord::Associations::BelongsToAssociation
- Defined in:
- lib/passive_record/associations/belongs_to.rb
Instance Attribute Summary collapse
-
#child_class ⇒ Object
Returns the value of attribute child_class.
-
#parent_class_name ⇒ Object
Returns the value of attribute parent_class_name.
-
#target_name_symbol ⇒ Object
Returns the value of attribute target_name_symbol.
Instance Method Summary collapse
Instance Attribute Details
#child_class ⇒ Object
Returns the value of attribute child_class
3 4 5 |
# File 'lib/passive_record/associations/belongs_to.rb', line 3 def child_class @child_class end |
#parent_class_name ⇒ Object
Returns the value of attribute parent_class_name
3 4 5 |
# File 'lib/passive_record/associations/belongs_to.rb', line 3 def parent_class_name @parent_class_name end |
#target_name_symbol ⇒ Object
Returns the value of attribute target_name_symbol
3 4 5 |
# File 'lib/passive_record/associations/belongs_to.rb', line 3 def target_name_symbol @target_name_symbol end |
Instance Method Details
#child_class_name ⇒ Object
16 17 18 |
# File 'lib/passive_record/associations/belongs_to.rb', line 16 def child_class_name child_class.name end |
#parent_class ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/passive_record/associations/belongs_to.rb', line 8 def parent_class @parent_class ||= ( module_name = child_class.name.deconstantize module_name = "Object" if module_name.empty? (module_name.constantize).const_get(parent_class_name) ) end |
#to_relation(child_model) ⇒ Object
4 5 6 |
# File 'lib/passive_record/associations/belongs_to.rb', line 4 def to_relation(child_model) BelongsToRelation.new(self, child_model) end |