Sha256: 230f99d51d7e1c83d81be6c99eead1026f238cf1f47bd94ed688e9b87f9ac0f9

Contents?: true

Size: 748 Bytes

Versions: 10

Compression:

Stored size: 748 Bytes

Contents

# frozen_string_literal: true
# encoding: utf-8

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

10 entries across 10 versions & 2 rubygems

Version Path
mongoid-7.1.11 lib/mongoid/matchable/regexp.rb
mongoid-7.1.10 lib/mongoid/matchable/regexp.rb
mongoid-7.1.9 lib/mongoid/matchable/regexp.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/mongoid-7.1.7/lib/mongoid/matchable/regexp.rb
mongoid-7.1.8 lib/mongoid/matchable/regexp.rb
mongoid-7.1.7 lib/mongoid/matchable/regexp.rb
mongoid-7.1.6 lib/mongoid/matchable/regexp.rb
mongoid-7.1.5 lib/mongoid/matchable/regexp.rb
mongoid-7.1.4 lib/mongoid/matchable/regexp.rb
mongoid-7.1.2 lib/mongoid/matchable/regexp.rb