class Mongoid::Association::Embedded::EmbeddedIn::Proxy
def binding
-
(Binding)- A binding object.
Other tags:
- Example: Get the binding. -
def binding Binding.new(_base, _target, _association) end
def characterize_one(document)
-
document(Document) -- The document to set the association metadata on.
Other tags:
- Example: Set the base association. -
def characterize_one(document) unless _base._association _base._association = _association.inverse_association(document) end end
def embedded?
-
(true)- true.
Other tags:
- Example: Is this association embedded? -
def embedded? true end
def initialize(base, target, association)
-
(In)- The proxy.
Parameters:
-
association(Association) -- The association metadata. -
target(Document) -- The target (parent) of the association. -
base(Document) -- The document the association hangs off of.
Other tags:
- Example: Create the new association. -
def initialize(base, target, association) init(base, target, association) do characterize_one(_target) bind_one end end
def path(document)
-
(Root)- The root atomic path calculator.
Parameters:
-
document(Document) -- The document to calculate on.
Other tags:
- Example: Get the path calculator. -
def path(document) Mongoid::Atomic::Paths::Root.new(document) end
def persistable?
-
(true | false)- If the association is persistable.
Other tags:
- Example: Can we persist the association? -
def persistable? _target.persisted? && !_binding? && !_building? end
def substitute(replacement)
-
(Document | nil)- The association or nil.
Parameters:
-
replacement(Document | Hash) -- A document to replace the target.
Other tags:
- Example: Substitute the new document. -
def substitute(replacement) unbind_one unless replacement _base.delete if persistable? return nil end _base.new_record = true replacement = Factory.build(klass, replacement) if replacement.is_a?(::Hash) self._target = replacement bind_one self end