Sha256: 822f3b3c652766ef4caf4279372e6ea7e4d170aee8e9e1171343ddb1c7d32504

Contents?: true

Size: 649 Bytes

Versions: 5

Compression:

Stored size: 649 Bytes

Contents

# encoding: utf-8
module Mongoid
  module Extensions
    module Regexp

      module ClassMethods

        # Turn the object from the ruby type we deal with to a Mongo friendly
        # type.
        #
        # @example Mongoize the object.
        #   Regexp.mongoize(/\A[abc]/)
        #
        # @param [ Regexp, String ] object The object to mongoize.
        #
        # @return [ Regexp ] The object mongoized.
        #
        # @since 3.0.0
        def mongoize(object)
          return nil if object.nil?
          ::Regexp.new(object)
        end
      end
    end
  end
end

::Regexp.extend(Mongoid::Extensions::Regexp::ClassMethods)

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mongoid-7.0.13 lib/mongoid/extensions/regexp.rb
mongoid-7.0.12 lib/mongoid/extensions/regexp.rb
mongoid-7.0.11 lib/mongoid/extensions/regexp.rb
mongoid-7.0.10 lib/mongoid/extensions/regexp.rb
mongoid-7.0.8 lib/mongoid/extensions/regexp.rb