class Mongoid::Association::Referenced::HasOne::Proxy
one-to-one between documents in different collections.
This class defines the behavior for all associations that are a
def binding
-
(Binding)- The binding object.
Other tags:
- Example: Get the binding. -
def binding HasOne::Binding.new(_base, _target, _association) end
def eager_loader(association, docs)
def eager_loader(association, docs) Eager.new(association, docs) end
def embedded?
-
(false)- Always false.
Other tags:
- Example: Is this association embedded? -
def embedded? false end
def initialize(base, target, association)
-
association(Association) -- The association metadata. -
target(Document) -- The target (child) of the association. -
base(Document) -- The document this association hangs off of.
Other tags:
- Example: Create the new association. -
def initialize(base, target, association) init(base, target, association) do raise_mixed if klass.embedded? && !klass.cyclic? characterize_one(_target) bind_one _target.save if persistable? end end
def nullify
- Example: Nullify the association. -
def nullify unbind_one _target.save end
def persistable?
-
(true | false)- If the association is persistable.
Other tags:
- Example: Can we persist the association? -
def persistable? _base.persisted? && !_binding? && !_building? end
def substitute(replacement)
-
(One)- The association.
Parameters:
-
replacement(Array) -- The replacement target.
Other tags:
- Example: Replace the association. -
def substitute(replacement) if self != replacement unbind_one if persistable? if _association.destructive? send(_association.dependent) else save if persisted? end end end HasOne::Proxy.new(_base, replacement, _association) if replacement end