Module: Mongoid::Matcher::FieldOperator Private

Defined in:
build/mongoid-7.3/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,
  '$bitsAllClear' => BitsAllClear,
  '$bitsAllSet' => BitsAllSet,
  '$bitsAnyClear' => BitsAnyClear,
  '$bitsAnySet' => BitsAnySet,
  '$elemMatch' => ElemMatch,
  '$eq' => Eq,
  '$exists' => Exists,
  '$gt' => Gt,
  '$gte' => Gte,
  '$in' => In,
  '$lt' => Lt,
  '$lte' => Lte,
  '$mod' => Mod,
  '$nin' => Nin,
  '$ne' => Ne,
  '$not' => Not,
  '$regex' => Regex,
  '$size' => Size,
  '$type' => Type,
}.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.



35
36
37
38
39
40
41
# File 'build/mongoid-7.3/lib/mongoid/matcher/field_operator.rb', line 35

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.



43
44
45
46
47
48
49
50
51
# File 'build/mongoid-7.3/lib/mongoid/matcher/field_operator.rb', line 43

module_function def apply_comparison_operator(operator, left, right)
  left.send(operator, right)
rescue ArgumentError, NoMethodError, TypeError
  # We silence bogus comparison attempts, e.g. number to string
  # comparisons.
  # Several different exceptions may be produced depending on the types
  # involved.
  false
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.



29
30
31
32
33
# File 'build/mongoid-7.3/lib/mongoid/matcher/field_operator.rb', line 29

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