module Mongoid::Criteria::Queryable::Extensions::String::ClassMethods
Public Instance Methods
__expr_part__(key, value, negating = false)
click to toggle source
Get the value as a expression.
@example Get the value as an expression.
String.__expr_part__("field", value)
@param [ String
, Symbol
] key The field key. @param [ Object
] value The value of the criteria. @param [ true, false ] negating If the selection should be negated.
@return [ Hash
] The selection.
@since 2.0.0
# File lib/mongoid/criteria/queryable/extensions/string.rb, line 107 def __expr_part__(key, value, negating = false) if negating { key => { "$#{value.regexp? ? "not" : "ne"}" => value }} else { key => value } end end
evolve(object)
click to toggle source
Evolves the string into a MongoDB friendly value - in this case a string.
@example Evolve the string
String.evolve(1)
@param [ Object
] object The object to convert.
@return [ String
] The value as a string.
@since 1.0.0
# File lib/mongoid/criteria/queryable/extensions/string.rb, line 126 def evolve(object) __evolve__(object) do |obj| obj.regexp? ? obj : obj.to_s end end