123456789_123456789_123456789_123456789_123456789_

Exception: Mongoid::Errors::InvalidQuery

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Subclasses:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, MongoidError, StandardError
Instance Chain:
self, MongoidError, StandardError
Inherits: Mongoid::Errors::MongoidError
Defined in: lib/mongoid/errors/invalid_query.rb

Overview

Raised when invalid query is passed to an embedded matcher, or an invalid query fragment is passed to the query builder (Criteria object).

Constant Summary

MongoidError - Inherited

BASE_KEY

Class Method Summary

  • .new(msg) ⇒ InvalidQuery constructor Internal use only Internal use only

    Create the new invalid query error.

  • .truncate_expr(expr) Internal use only Internal use only

    Stringifies the argument using #inspect and truncates the result to about 100 characters.

Instance Attribute Summary

Instance Method Summary

MongoidError - Inherited

#compose_message

Compose the message.

#translate

Given the key of the specific error and the options hash, translate the message.

#translate_problem

Create the problem.

#translate_resolution

Create the resolution.

#translate_summary

Create the summary.

Class Method Details

.truncate_expr(expr)

This method is for internal use only.

Stringifies the argument using #inspect and truncates the result to about 100 characters.

Parameters:

  • expr (Object)

    An expression to stringify and truncate.

[ GitHub ]

  
# File 'lib/mongoid/errors/invalid_query.rb', line 24

def self.truncate_expr(expr)
  unless expr.is_a?(String)
    expr = expr.inspect
  end

  if expr.length > 103
    expr = if expr =~ /\A<#((?:.|\n)*)>\z/
      "<##{expr.slice(0, 97)}...>"
    else
      expr.slice(0, 100) + '...'
    end
  end

  expr
end