Sha256: 16965d807eccac0c6a1b364fcf4a82f944c97473055368abb031f135e7970fe5

Contents?: true

Size: 1.24 KB

Versions: 24

Compression:

Stored size: 1.24 KB

Contents

# frozen_string_literal: true

module Mongoid
  module Extensions
    module ObjectId

      # Evolve the object id.
      #
      # @example Evolve the object id.
      #   object_id.__evolve_object_id__
      #
      # @return [ BSON::ObjectId ] self.
      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.
        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.
        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

24 entries across 24 versions & 1 rubygems

Version Path
mongoid-8.1.7 lib/mongoid/extensions/object_id.rb
mongoid-8.1.6 lib/mongoid/extensions/object_id.rb
mongoid-8.0.8 lib/mongoid/extensions/object_id.rb
mongoid-8.1.5 lib/mongoid/extensions/object_id.rb
mongoid-8.1.4 lib/mongoid/extensions/object_id.rb
mongoid-8.0.7 lib/mongoid/extensions/object_id.rb
mongoid-8.1.3 lib/mongoid/extensions/object_id.rb
mongoid-8.1.2 lib/mongoid/extensions/object_id.rb
mongoid-8.0.6 lib/mongoid/extensions/object_id.rb
mongoid-7.5.4 lib/mongoid/extensions/object_id.rb
mongoid-8.1.1 lib/mongoid/extensions/object_id.rb
mongoid-8.0.5 lib/mongoid/extensions/object_id.rb
mongoid-8.1.0 lib/mongoid/extensions/object_id.rb
mongoid-7.5.3 lib/mongoid/extensions/object_id.rb
mongoid-8.0.4 lib/mongoid/extensions/object_id.rb
mongoid-8.0.3 lib/mongoid/extensions/object_id.rb
mongoid-7.5.2 lib/mongoid/extensions/object_id.rb
mongoid-8.0.2 lib/mongoid/extensions/object_id.rb
mongoid-7.5.1 lib/mongoid/extensions/object_id.rb
mongoid-7.4.3 lib/mongoid/extensions/object_id.rb