Sha256: e26d1235a8cd3b941ec1d842df2691df14da5a719aab8d4f2aa3da1968dde69b

Contents?: true

Size: 1.29 KB

Versions: 27

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true
# encoding: utf-8

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.
          # @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

27 entries across 27 versions & 2 rubygems

Version Path
mongoid-7.3.5 lib/mongoid/association/embedded/embedded_in/buildable.rb
mongoid-7.3.4 lib/mongoid/association/embedded/embedded_in/buildable.rb
mongoid-7.1.11 lib/mongoid/association/embedded/embedded_in/buildable.rb
mongoid-7.2.6 lib/mongoid/association/embedded/embedded_in/buildable.rb
mongoid-7.3.3 lib/mongoid/association/embedded/embedded_in/buildable.rb
mongoid-7.3.2 lib/mongoid/association/embedded/embedded_in/buildable.rb
mongoid-7.2.5 lib/mongoid/association/embedded/embedded_in/buildable.rb
mongoid-7.1.10 lib/mongoid/association/embedded/embedded_in/buildable.rb
mongoid-7.1.9 lib/mongoid/association/embedded/embedded_in/buildable.rb
mongoid-7.2.4 lib/mongoid/association/embedded/embedded_in/buildable.rb
mongoid-7.3.1 lib/mongoid/association/embedded/embedded_in/buildable.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/mongoid-7.1.7/lib/mongoid/association/embedded/embedded_in/buildable.rb
mongoid-7.3.0 lib/mongoid/association/embedded/embedded_in/buildable.rb
mongoid-7.2.3 lib/mongoid/association/embedded/embedded_in/buildable.rb
mongoid-7.1.8 lib/mongoid/association/embedded/embedded_in/buildable.rb
mongoid-7.2.2 lib/mongoid/association/embedded/embedded_in/buildable.rb
mongoid-7.2.1 lib/mongoid/association/embedded/embedded_in/buildable.rb
mongoid-7.1.7 lib/mongoid/association/embedded/embedded_in/buildable.rb
mongoid-7.2.0 lib/mongoid/association/embedded/embedded_in/buildable.rb
mongoid-7.1.6 lib/mongoid/association/embedded/embedded_in/buildable.rb