module Mongoid::Association::Embedded::EmbedsMany::Buildable
def build(base, object, type = nil, selected_fields = nil)
-
(Array
- Array
Parameters:
-
selected_fields
(Hash
) -- Fields which were retrieved via -
type
(String
) -- Not used in this context. -
object
(Array
) -- The object to use| Array -
base
(Document
) -- The base object.
Other tags:
- Example: Build the documents. -
def build(base, object, type = nil, selected_fields = nil) return [] if object.blank? return object if object.first.is_a?(Document) docs = [] object.each do |attrs| if _loading? && base.persisted? docs.push(Factory.execute_from_db(klass, attrs, nil, selected_fields, execute_callbacks: false)) else docs.push(Factory.build(klass, attrs)) end end docs end