Class: Mongoid::Relations::Builders::Embedded::Many
- Inherits:
-
Mongoid::Relations::Builder
- Object
- Mongoid::Relations::Builder
- Mongoid::Relations::Builders::Embedded::Many
- Defined in:
- lib/mongoid/relations/builders/embedded/many.rb
Overview
:nodoc:
Instance Attribute Summary
Attributes inherited from Mongoid::Relations::Builder
Instance Method Summary collapse
-
#build(type = nil) ⇒ Array<Document ] The documents.
Builds the document out of the attributes using the provided metadata on the relation.
Methods inherited from Mongoid::Relations::Builder
Constructor Details
This class inherits a constructor from Mongoid::Relations::Builder
Instance Method Details
#build(type = nil) ⇒ Array<Document ] The documents.
Builds the document out of the attributes using the provided metadata on the relation. Instantiates through the factory in order to make sure subclasses and allocation are used if fitting. This case will return many documents.
19 20 21 22 23 24 25 26 27 |
# File 'lib/mongoid/relations/builders/embedded/many.rb', line 19 def build(type = nil) return [] if object.blank? return object if object.first.is_a?(Document) object.inject([]) do |documents, attrs| documents.tap do |docs| docs << Mongoid::Factory.from_db(.klass, attrs) end end end |