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, #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
#conditions ⇒ Object
26 27 28 |
# File 'lib/active_record/associations/belongs_to_polymorphic_association.rb', line 26 def conditions @conditions ||= @reflection.[:conditions] && interpolate_and_sanitize_sql(@reflection.[:conditions], nil, association_class) end |
#replace(record) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/active_record/associations/belongs_to_polymorphic_association.rb', line 5 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(record) @owner[@reflection.[:foreign_type]] = record.class.base_class.name.to_s @updated = true end set_inverse_instance(record, @owner) loaded record end |
#updated? ⇒ Boolean
22 23 24 |
# File 'lib/active_record/associations/belongs_to_polymorphic_association.rb', line 22 def updated? @updated end |