Exception: Mongoid::Errors::InvalidElemMatchOperator

Inherits:
InvalidQuery show all
Defined in:
build/mongoid-master/lib/mongoid/errors/invalid_elem_match_operator.rb

Overview

Raised when invalid field-level operator is passed to the $elemMatch embedded matcher.

Constant Summary collapse

VALID_OPERATORS =

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.

%w(
  and all eq exists gt gte in lt lte ne nin nor not or regex size
).freeze

Constants inherited from MongoidError

MongoidError::BASE_KEY

Instance Attribute Summary collapse

Attributes inherited from MongoidError

#problem, #resolution, #summary

Instance Method Summary collapse

Methods inherited from InvalidQuery

truncate_expr

Methods inherited from MongoidError

#compose_message

Constructor Details

#initialize(operator) ⇒ InvalidElemMatchOperator

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.

Creates the exception.

Parameters:

  • operator (String)

    The operator that was used.



21
22
23
24
25
26
27
# File 'build/mongoid-master/lib/mongoid/errors/invalid_elem_match_operator.rb', line 21

def initialize(operator)
  @operator = operator
  super(compose_message("invalid_elem_match_operator",
    operator: operator,
    valid_operators: VALID_OPERATORS.map { |op| "'$#{op}'" }.join(', '),
  ))
end

Instance Attribute Details

#operatorString (readonly)

Returns The operator that was used.

Returns:

  • (String)

    The operator that was used.



30
31
32
# File 'build/mongoid-master/lib/mongoid/errors/invalid_elem_match_operator.rb', line 30

def operator
  @operator
end