Module: Mongoid::Matcher::FieldOperator Private

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

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.

Constant Summary collapse

MAP =

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

{
  '$all' => All,
  '$elemMatch' => ElemMatch,
  '$eq' => Eq,
  '$exists' => Exists,
  '$gt' => Gt,
  '$gte' => Gte,
  '$in' => In,
  '$lt' => Lt,
  '$lte' => Lte,
  '$nin' => Nin,
  '$ne' => Ne,
  '$not' => Not,
  '$regex' => Regex,
  '$size' => Size,
}.freeze

Class Method Summary collapse

Class Method Details

.apply_array_field_operator(exists, value, condition) ⇒ Object

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.



29
30
31
32
33
34
35
# File 'lib/mongoid/matcher/field_operator.rb', line 29

module_function def apply_array_field_operator(exists, value, condition)
  if Array === value
    value.any? { |v| yield v }
  else
    yield value
  end
end

.apply_comparison_operator(operator, left, right) ⇒ Object

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.



37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/mongoid/matcher/field_operator.rb', line 37

module_function def apply_comparison_operator(operator, left, right)
  case left
  when Numeric
    case right
    when Numeric
      left.send(operator, right)
    else
      false
    end
  else
    false
  end
end

.get(op) ⇒ Object

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.



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

module_function def get(op)
  MAP.fetch(op)
rescue KeyError
  raise Errors::InvalidFieldOperator.new(op)
end