Class: MassiveRecord::ORM::Relations::Proxy::ReferencesOnePolymorphic

Inherits:
MassiveRecord::ORM::Relations::Proxy show all
Defined in:
lib/massive_record/orm/relations/proxy/references_one_polymorphic.rb

Instance Attribute Summary

Attributes inherited from MassiveRecord::ORM::Relations::Proxy

#metadata, #proxy_owner, #proxy_target

Instance Method Summary collapse

Methods inherited from MassiveRecord::ORM::Relations::Proxy

#blank?, #initialize, #inspect, #is_a?, #load_proxy_target, #loaded!, #loaded?, #method_missing, #reload, #reset, #respond_to?, #to_param

Constructor Details

This class inherits a constructor from MassiveRecord::ORM::Relations::Proxy

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class MassiveRecord::ORM::Relations::Proxy

Instance Method Details

#proxy_target=(proxy_target) ⇒ Object



6
7
8
9
# File 'lib/massive_record/orm/relations/proxy/references_one_polymorphic.rb', line 6

def proxy_target=(proxy_target)
  set_foreign_key_and_type_in_proxy_owner(proxy_target.id, proxy_target.class.to_s) if proxy_target
  super(proxy_target)
end

#proxy_target_classObject



11
12
13
# File 'lib/massive_record/orm/relations/proxy/references_one_polymorphic.rb', line 11

def proxy_target_class
  proxy_owner.send(.polymorphic_type_column).classify.constantize
end

#replace(proxy_target) ⇒ Object



15
16
17
18
# File 'lib/massive_record/orm/relations/proxy/references_one_polymorphic.rb', line 15

def replace(proxy_target)
  super
  set_foreign_key_and_type_in_proxy_owner(nil, nil) if proxy_target.nil?
end