Class: Mongoid::Association::Embedded::EmbeddedIn::Proxy
- Defined in:
- lib/mongoid/association/embedded/embedded_in/proxy.rb
Instance Attribute Summary
Attributes inherited from Proxy
#_association, #_base, #_target
Class Method Summary collapse
-
.embedded? ⇒ true
Returns true if the association is an embedded one.
-
.path(document) ⇒ Root
Get the path calculator for the supplied document.
Instance Method Summary collapse
-
#initialize(base, target, association) ⇒ In
constructor
Instantiate a new embedded_in association.
-
#substitute(replacement) ⇒ Document?
Substitutes the supplied target documents for the existing document in the association.
Methods inherited from One
#__evolve_object_id__, #clear, #in_memory, #respond_to?
Methods inherited from Proxy
apply_ordering, #extend_proxies, #init, #klass, #reset_unloaded, #substitutable
Methods included from Marshalable
Constructor Details
#initialize(base, target, association) ⇒ In
Instantiate a new embedded_in association.
20 21 22 23 24 25 |
# File 'lib/mongoid/association/embedded/embedded_in/proxy.rb', line 20 def initialize(base, target, association) init(base, target, association) do characterize_one(_target) bind_one end end |
Class Method Details
.embedded? ⇒ true
Returns true if the association is an embedded one. In this case always true.
91 92 93 |
# File 'lib/mongoid/association/embedded/embedded_in/proxy.rb', line 91 def true end |
Instance Method Details
#substitute(replacement) ⇒ Document?
Substitutes the supplied target documents for the existing document in the association.
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/mongoid/association/embedded/embedded_in/proxy.rb', line 36 def substitute(replacement) unbind_one unless replacement _base.delete if persistable? return nil end _base.new_record = true self._target = replacement bind_one self end |