Module: Mongoid::Association::Referenced::BelongsTo::Buildable
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Defined in: | lib/mongoid/association/referenced/belongs_to/buildable.rb |
Overview
The Builder behavior for belongs_to associations.
Instance Method Summary
-
#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.
- #execute_query(object, type) private
- #query?(object) ⇒ Boolean private
- #query_criteria(object, type) private
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.
# File 'lib/mongoid/association/referenced/belongs_to/buildable.rb', line 24
def build(base, object, type = nil, selected_fields = nil) return object unless query?(object) execute_query(object, type) end
#execute_query(object, type) (private)
[ GitHub ]# File 'lib/mongoid/association/referenced/belongs_to/buildable.rb', line 31
def execute_query(object, type) query_criteria(object, type).take end