Module: Mongoid::Association::Referenced::HasOne::Buildable
- Included in:
- Mongoid::Association::Referenced::HasOne
- Defined in:
- lib/mongoid/association/referenced/has_one/buildable.rb
Overview
The Builder behavior for has_one associations.
Instance Method Summary collapse
-
#build(base, object, type = nil, selected_fields = nil) ⇒ Document
This method either takes an _id or an object and queries for the inverse side using the id or sets the object after clearing the associated object.
Instance Method Details
#build(base, object, type = nil, selected_fields = nil) ⇒ Document
This method either takes an _id or an object and queries for the inverse side using the id or sets the object after clearing the associated object.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/mongoid/association/referenced/has_one/buildable.rb', line 22 def build(base, object, type = nil, selected_fields = nil) if query?(object) if !base.new_record? execute_query(object, base) end else clear_associated(object) object end end |