Class: ActiveRecord::Associations::BelongsToPolymorphicAssociation
- Inherits:
-
AssociationProxy
- Object
- AssociationProxy
- ActiveRecord::Associations::BelongsToPolymorphicAssociation
- Defined in:
- lib/active_record/associations/belongs_to_polymorphic_association.rb
Overview
:nodoc:
Instance Method Summary collapse
Methods inherited from AssociationProxy
#===, #aliased_table_name, #conditions, #initialize, #inspect, #loaded, #loaded?, #proxy_owner, #proxy_reflection, #proxy_respond_to?, #proxy_target, #reload, #reset, #respond_to?, #send, #target, #target=
Constructor Details
This class inherits a constructor from ActiveRecord::Associations::AssociationProxy
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class ActiveRecord::Associations::AssociationProxy
Instance Method Details
#replace(record) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/active_record/associations/belongs_to_polymorphic_association.rb', line 4 def replace(record) if record.nil? @target = @owner[@reflection.primary_key_name] = @owner[@reflection.[:foreign_type]] = nil else @target = (AssociationProxy === record ? record.target : record) @owner[@reflection.primary_key_name] = record.id @owner[@reflection.[:foreign_type]] = record.class.base_class.name.to_s @updated = true end loaded record end |
#updated? ⇒ Boolean
20 21 22 |
# File 'lib/active_record/associations/belongs_to_polymorphic_association.rb', line 20 def updated? @updated end |