Sha256: 0635828b0c28b2171c109a0b1d3dad4a41c656fdb80a52553afe39cc619a6078

Contents?: true

Size: 1.35 KB

Versions: 27

Compression:

Stored size: 1.35 KB

Contents

# frozen_string_literal: true
# encoding: utf-8

module Mongoid
  module Extensions
    module ObjectId

      # Evolve the object id.
      #
      # @example Evolve the object id.
      #   object_id.__evolve_object_id__
      #
      # @return [ BSON::ObjectId ] self.
      #
      # @since 3.0.0
      def __evolve_object_id__
        self
      end
      alias :__mongoize_object_id__ :__evolve_object_id__

      module ClassMethods

        # Evolve the object into a mongo-friendly value to query with.
        #
        # @example Evolve the object.
        #   ObjectId.evolve(id)
        #
        # @param [ Object ] object The object to evolve.
        #
        # @return [ BSON::ObjectId ] The object id.
        #
        # @since 3.0.0
        def evolve(object)
          object.__evolve_object_id__
        end

        # Convert the object into a mongo-friendly value to store.
        #
        # @example Convert the object.
        #   ObjectId.mongoize(id)
        #
        # @param [ Object ] object The object to convert.
        #
        # @return [ BSON::ObjectId ] The object id.
        #
        # @since 3.0.0
        def mongoize(object)
          object.__mongoize_object_id__
        end
      end
    end
  end
end

BSON::ObjectId.__send__(:include, Mongoid::Extensions::ObjectId)
BSON::ObjectId.extend(Mongoid::Extensions::ObjectId::ClassMethods)

Version data entries

27 entries across 27 versions & 2 rubygems

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