module Mongoid::Matcher::Exists

In-memory matcher for $exists expression.

@see www.mongodb.com/docs/manual/reference/operator/query/exists/

@api private

Public Instance Methods

matches?(exists, value, condition) click to toggle source

Returns whether an $exists expression is satisfied.

@param [ true | false ] exists Whether the value exists. @param [ Object ] value Not used. @param [ true | false ] condition The $exists condition predicate.

@return [ true | false ] Whether the existence condition is met.

@api private

# File lib/mongoid/matcher/exists.rb, line 21
                def matches?(exists, value, condition)
  case condition
  when Range
    raise Errors::InvalidQuery, "$exists argument cannot be a Range: #{Errors::InvalidQuery.truncate_expr(condition)}"
  end
  exists == (condition || false)
end