Sha256: 38194358d42a345d66dda6718e059267e1afd8b4f0e2c6be3496162a6f82361f

Contents?: true

Size: 1017 Bytes

Versions: 14

Compression:

Stored size: 1017 Bytes

Contents

module Mongoid
  module Association
    module Embedded
      class EmbeddedIn

        # The Builder behavior for embedded_in associations.
        #
        # @since 7.0
        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.
          #
          # @return [ Document ] A single document.
          def build(base, object, type = nil)
            return object unless object.is_a?(Hash)
            if _loading?
              Factory.from_db(klass, object)
            else
              Factory.build(klass, object)
            end
          end
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
mongoid-7.0.13 lib/mongoid/association/embedded/embedded_in/buildable.rb
mongoid-7.0.12 lib/mongoid/association/embedded/embedded_in/buildable.rb
mongoid-7.0.11 lib/mongoid/association/embedded/embedded_in/buildable.rb
mongoid-7.0.10 lib/mongoid/association/embedded/embedded_in/buildable.rb
mongoid-7.0.8 lib/mongoid/association/embedded/embedded_in/buildable.rb
mongoid-7.0.7 lib/mongoid/association/embedded/embedded_in/buildable.rb
mongoid-7.0.6 lib/mongoid/association/embedded/embedded_in/buildable.rb
mongoid-7.0.5 lib/mongoid/association/embedded/embedded_in/buildable.rb
mongoid-7.0.4 lib/mongoid/association/embedded/embedded_in/buildable.rb
mongoid-7.0.3 lib/mongoid/association/embedded/embedded_in/buildable.rb
mongoid-7.0.2 lib/mongoid/association/embedded/embedded_in/buildable.rb
mongoid-7.0.1 lib/mongoid/association/embedded/embedded_in/buildable.rb
mongoid-7.0.0 lib/mongoid/association/embedded/embedded_in/buildable.rb
mongoid-7.0.0.beta lib/mongoid/association/embedded/embedded_in/buildable.rb