Sha256: 984ee349f7c9428b05f068ed3eaa0642314dbc6e92bdf6adb9e9f291f43a3772
Contents?: true
Size: 1.04 KB
Versions: 2
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.from_db(metadata.klass, attrs) end end end end end end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
mongoid-braxton-2.0.2 | lib/mongoid/relations/builders/embedded/many.rb |
mongoid-2.0.2 | lib/mongoid/relations/builders/embedded/many.rb |