Module: Mongoid::Matcher::Exists Private

Defined in:
lib/mongoid/matcher/exists.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

In-memory matcher for $exists expression.

Class Method Summary collapse

Class Method Details

.matches?(exists, value, condition) ⇒ true | false, Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns whether an $exists expression is satisfied.

Parameters:

  • exists (true | false)

    Whether the value exists.

  • value (Object)

    Not used.

  • condition (true | false)

    The $exists condition predicate.

Returns:

  • (true | false)

    Whether the existence condition is met.

  • (Boolean)


21
22
23
24
25
26
27
# File 'lib/mongoid/matcher/exists.rb', line 21

module_function 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