Sha256: a60cd393ba8eb5281f96d01083d636c3dfe77f535bbab83a7ac2db4e1520d1b3
Contents?: true
Size: 1.04 KB
Versions: 11
Compression:
Stored size: 1.04 KB
Contents
# encoding: utf-8 module Mongoid # :nodoc: module Relations #:nodoc: module Builders #:nodoc: module Embedded #:nodoc: class Many < Builder #:nodoc: # 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. # # @example Build the documents. # Builder.new(meta, attrs).build # # @param [ String ] type Not used in this context. # # @return [ Array<Document ] The documents. 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.build(metadata.klass, attrs) end end end end end end end end
Version data entries
11 entries across 11 versions & 2 rubygems