Sha256: c51c15477479bdadce72e0ef1e585f8d9e04c91925722ae06cfa58b43fd94582
Contents?: true
Size: 1.25 KB
Versions: 17
Compression:
Stored size: 1.25 KB
Contents
# frozen_string_literal: true module Mongoid module Association module Embedded class EmbeddedIn # The Builder behavior for embedded_in associations. module Buildable include Threaded::Lifecycle # This builder doesn't actually build anything, just returns the # parent since it should already be instantiated. # # @example Build the document. # Builder.new(meta, attrs).build # # @param [ Object ] base The object. # @param [ Object ] object The parent hash or document. # @param [ String ] type Not used in this context. # @param [ Hash ] selected_fields Fields which were retrieved via # #only. If selected_fields are specified, fields not listed in it # will not be accessible in the built document. # # @return [ Document ] A single document. def build(base, object, type = nil, selected_fields = nil) return object unless object.is_a?(Hash) if _loading? Factory.from_db(klass, object, nil, selected_fields) else Factory.build(klass, object) end end end end end end end
Version data entries
17 entries across 17 versions & 1 rubygems