Sha256: 78c6d46f884bf9824d26becb0c8267445963438713f39090abe10b24964c6b65

Contents?: true

Size: 699 Bytes

Versions: 5

Compression:

Stored size: 699 Bytes

Contents

module Mongoid
  module Matchable

    # Defines behavior for handling regular expressions in embedded documents.
    class Regexp < Default

      # Does the supplied query match the attribute?
      #
      # @example Does this match?
      #   matcher._matches?(/\AEm/)
      #   matcher._matches?(BSON::Regex::Raw.new("\\AEm"))
      #
      # @param [ BSON::Regexp::Raw, Regexp ] regexp The regular expression object.
      #
      # @return [ true, false ] True if matches, false if not.
      #
      # @since 5.2.1
      def _matches?(regexp)
        if native_regexp = regexp.try(:compile)
          super(native_regexp)
        else
          super
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

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