Sha256: 3f388b7720fa16f39db5953cc423f8044311437ae9d4555a1108affd40dc8ecd

Contents?: true

Size: 1.32 KB

Versions: 68

Compression:

Stored size: 1.32 KB

Contents

# 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

68 entries across 63 versions & 3 rubygems

Version Path
mongoid-7.0.13 lib/mongoid/extensions/object_id.rb
mongoid-7.0.12 lib/mongoid/extensions/object_id.rb
mongoid-6.4.8 lib/mongoid/extensions/object_id.rb
mongoid-7.0.11 lib/mongoid/extensions/object_id.rb
mongoid-7.0.10 lib/mongoid/extensions/object_id.rb
mongoid-6.4.7 lib/mongoid/extensions/object_id.rb
mongoid-6.4.5 lib/mongoid/extensions/object_id.rb
mongoid-7.0.8 lib/mongoid/extensions/object_id.rb
mongoid-7.0.7 lib/mongoid/extensions/object_id.rb
mongoid-7.0.6 lib/mongoid/extensions/object_id.rb
mongoid-5.4.1 lib/mongoid/extensions/object_id.rb
mongoid-7.0.5 lib/mongoid/extensions/object_id.rb
mongoid-7.0.4 lib/mongoid/extensions/object_id.rb
mongoid-6.4.4 lib/mongoid/extensions/object_id.rb
mongoid-7.0.3 lib/mongoid/extensions/object_id.rb
mongoid-6.4.2 lib/mongoid/extensions/object_id.rb
mongoid-7.0.2 lib/mongoid/extensions/object_id.rb
mongoid-7.0.1 lib/mongoid/extensions/object_id.rb
mongoid-6.4.1 lib/mongoid/extensions/object_id.rb
mongoid-5.4.0 lib/mongoid/extensions/object_id.rb