class Mongoid::Matchable::Regexp

Defines behavior for handling regular expressions in embedded documents.

Public Instance Methods

_matches?(regexp) click to toggle source

Does the supplied query match the attribute?

@example Does this match?

matcher._matches?(/^Em/)
matcher._matches?(BSON::Regex::Raw.new("^Em"))

@param [ BSON::Regexp::Raw, Regexp ] regexp The regular expression object.

@return [ true, false ] True if matches, false if not.

@since 5.2.1

Calls superclass method Mongoid::Matchable::Default#_matches?
# File lib/mongoid/matchable/regexp.rb, line 18
def _matches?(regexp)
  if native_regexp = regexp.try(:compile)
    super(native_regexp)
  else
    super
  end
end