module Mongoid::Association::Embedded::EmbedsOne::Buildable
def build(base, object, _type = nil, selected_fields = nil)
-
(Document)- A single document.
Parameters:
-
selected_fields(Hash) -- Fields which were retrieved via -
_type(String) -- Not used in this context. -
object(Document | Hash) -- The related document. -
base(Document) -- The document this association hangs off of.
Other tags:
- Example: Build the document. -
def build(base, object, _type = nil, selected_fields = nil) if object.is_a?(Hash) if _loading? && base.persisted? Factory.execute_from_db(klass, object, nil, selected_fields, execute_callbacks: false) else Factory.build(klass, object) end else clear_associated(object) object end end
def clear_associated(doc)
def clear_associated(doc) if doc && (inv = inverse(doc)) if associated = doc.ivar(inv) associated.substitute(nil) end end end