lib/mongoid/criteria/queryable/extensions/string.rb in mongoid-8.0.3 vs lib/mongoid/criteria/queryable/extensions/string.rb in mongoid-8.0.4
- old
+ new
@@ -47,11 +47,11 @@
# @return [ Hash ] The string as a sort option hash.
def __sort_option__
split(/,/).inject({}) do |hash, spec|
hash.tap do |_hash|
field, direction = spec.strip.split(/\s/)
- _hash[field.to_sym] = direction.to_direction
+ _hash[field.to_sym] = Mongoid::Criteria::Translator.to_direction(direction)
end
end
end
# Get the string as a specification.
@@ -63,19 +63,9 @@
# @param [ true | false ] negating If the selection should be negated.
#
# @return [ Hash ] The selection.
def __expr_part__(value, negating = false)
::String.__expr_part__(self, value, negating)
- end
-
- # Get the string as a sort direction.
- #
- # @example Get the string as a sort direction.
- # "1".to_direction
- #
- # @return [ Integer ] The direction.
- def to_direction
- self =~ /desc/i ? -1 : 1
end
module ClassMethods
# Get the value as a expression.