Method: Mongoid::Errors::InvalidQuery.truncate_expr
- Defined in:
- lib/mongoid/errors/invalid_query.rb
.truncate_expr(expr) ⇒ 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.
Stringifies the argument using #inspect and truncates the result to about 100 characters.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# 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 |