Class: MassiveRecord::ORM::Relations::Proxy::EmbeddedIn
- Inherits:
-
MassiveRecord::ORM::Relations::Proxy
- Object
- MassiveRecord::ORM::Relations::Proxy
- MassiveRecord::ORM::Relations::Proxy::EmbeddedIn
- Defined in:
- lib/massive_record/orm/relations/proxy/embedded_in.rb
Direct Known Subclasses
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, #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
#replace(proxy_target, update_inverse_relation = true) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/massive_record/orm/relations/proxy/embedded_in.rb', line 7 def replace(proxy_target, update_inverse_relation = true) proxy_target_was = self.proxy_target super(proxy_target).tap do |proxy_target_is| if update_inverse_relation if proxy_target_is.present? unless proxy_target_is.respond_to? .inverse_of raise RelationMissing.new( <<-TXT Expected '#{.proxy_target_class}' to have an embedded relation defined with name '#{.inverse_of}'. TXT ) end if proxy_target_was.nil? proxy_target_is.send(.inverse_of).push proxy_owner elsif proxy_target_was != proxy_target_is proxy_target_was.send(.inverse_of).delete(proxy_owner) proxy_target_was.save if proxy_target_was.persisted? proxy_target_is.send(.inverse_of).push proxy_owner end end end end end |
#reset(force = false) ⇒ Object
34 35 36 37 38 |
# File 'lib/massive_record/orm/relations/proxy/embedded_in.rb', line 34 def reset(force = false) # Does nothing.. if we are resetting this inside of an embedded setting # we will lose the knowledge about parent. super if force end |