Exception: Mongoid::Errors::InvalidFieldOperator

Inherits:
InvalidQuery show all
Defined in:
build/mongoid-8.1/lib/mongoid/errors/invalid_field_operator.rb

Overview

Raised when invalid field-level operator is passed to an 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(
  all elemMatch eq exists gt gte in lt lte ne nin not 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) ⇒ InvalidFieldOperator

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.



20
21
22
23
24
25
26
# File 'build/mongoid-8.1/lib/mongoid/errors/invalid_field_operator.rb', line 20

def initialize(operator)
  @operator = operator
  super(compose_message("invalid_field_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.



29
30
31
# File 'build/mongoid-8.1/lib/mongoid/errors/invalid_field_operator.rb', line 29

def operator
  @operator
end