class Mongoid::Errors::InvalidQuery
Raised when invalid query is passed to an embedded matcher, or an invalid query fragment is passed to the query builder (Criteria
object).
Public Class Methods
new(msg)
click to toggle source
Create the new invalid query error.
@api private
Calls superclass method
# File lib/mongoid/errors/invalid_query.rb, line 14 def initialize(msg) super end
truncate_expr(expr)
click to toggle source
Stringifies the argument using inspect and truncates the result to about 100 characters.
@param [ Object
] expr An expression to stringify and truncate.
@api private
# 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