Module: Mongoid::Matcher::Mod Private

Defined in:
lib/mongoid/matcher/mod.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 $mod 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 a value satisfies a $mod expression.



22
23
24
25
26
27
28
29
30
# File 'lib/mongoid/matcher/mod.rb', line 22

module_function def matches?(exists, value, condition)
  unless Array === condition
    raise Errors::InvalidQuery, "Unknown $mod argument #{condition}"
  end
  if condition.length != 2
    raise Errors::InvalidQuery, "Malformed $mod argument #{condition}, should have 2 elements"
  end
  condition[1] == value%condition[0]
end