Module: Mongoid::Association::Referenced::HasMany::Buildable
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Defined in: | lib/mongoid/association/referenced/has_many/buildable.rb |
Overview
The Builder behavior for has_many 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.
- #query?(object) ⇒ Boolean 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/has_many/buildable.rb', line 24
def build(base, object, type = nil, selected_fields = nil) return (object || []) unless query?(object) return [] if object.is_a?(Array) query_criteria(object, base) end