Class: Syncano::ActiveRecord::Association::BelongsTo
- Defined in:
- lib/syncano/active_record/association/belongs_to.rb
Overview
Class for belongs to association
Instance Attribute Summary collapse
-
#associated_model ⇒ Object
readonly
Returns the value of attribute associated_model.
-
#foreign_key ⇒ Object
readonly
Returns the value of attribute foreign_key.
-
#source_model ⇒ Object
readonly
Returns the value of attribute source_model.
Instance Method Summary collapse
-
#belongs_to? ⇒ TrueClass
Checks if association is belongs_to type.
-
#initialize(source_model, name) ⇒ BelongsTo
constructor
Constructor for belongs_to association.
Methods inherited from Base
Constructor Details
#initialize(source_model, name) ⇒ BelongsTo
Constructor for belongs_to association
13 14 15 16 |
# File 'lib/syncano/active_record/association/belongs_to.rb', line 13 def initialize(source_model, name) super self.foreign_key = associated_model.name.foreign_key end |
Instance Attribute Details
#associated_model ⇒ Object
Returns the value of attribute associated_model.
8 9 10 |
# File 'lib/syncano/active_record/association/belongs_to.rb', line 8 def associated_model @associated_model end |
#foreign_key ⇒ Object
Returns the value of attribute foreign_key.
8 9 10 |
# File 'lib/syncano/active_record/association/belongs_to.rb', line 8 def foreign_key @foreign_key end |
#source_model ⇒ Object
Returns the value of attribute source_model.
8 9 10 |
# File 'lib/syncano/active_record/association/belongs_to.rb', line 8 def source_model @source_model end |
Instance Method Details
#belongs_to? ⇒ TrueClass
Checks if association is belongs_to type
20 21 22 |
# File 'lib/syncano/active_record/association/belongs_to.rb', line 20 def belongs_to? true end |