Class: ActiveRecord::Associations::BelongsToAssociation
- Inherits:
-
SingularAssociation
- Object
- Association
- SingularAssociation
- ActiveRecord::Associations::BelongsToAssociation
- Defined in:
- activerecord/lib/active_record/associations/belongs_to_association.rb
Overview
:nodoc:
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Association
Instance Method Summary collapse
Methods inherited from SingularAssociation
#build, #create, #create!, #reader, #writer
Methods inherited from Association
#aliased_table_name, #association_scope, #initialize, #initialize_attributes, #interpolate, #klass, #load_target, #loaded!, #loaded?, #marshal_dump, #marshal_load, #reload, #reset_scope, #scope, #set_inverse_instance, #stale_target?, #target_scope
Constructor Details
This class inherits a constructor from ActiveRecord::Associations::Association
Instance Method Details
#handle_dependency ⇒ Object
6 7 8 |
# File 'activerecord/lib/active_record/associations/belongs_to_association.rb', line 6 def handle_dependency target.send([:dependent]) if load_target end |
#replace(record) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'activerecord/lib/active_record/associations/belongs_to_association.rb', line 10 def replace(record) raise_on_type_mismatch!(record) if record update_counters(record) replace_keys(record) set_inverse_instance(record) @updated = true if record self.target = record end |
#reset ⇒ Object
22 23 24 25 |
# File 'activerecord/lib/active_record/associations/belongs_to_association.rb', line 22 def reset super @updated = false end |
#updated? ⇒ Boolean
27 28 29 |
# File 'activerecord/lib/active_record/associations/belongs_to_association.rb', line 27 def updated? @updated end |