We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b3b9aa9 commit bc14f74Copy full SHA for bc14f74
lib/mongoid/criteria/queryable/extensions/numeric.rb
@@ -43,7 +43,21 @@ module ClassMethods
43
# @return [ Integer ] The evolved object.
44
def evolve(object)
45
__evolve__(object) do |obj|
46
- obj.to_s.match?(/\A[-+]?[0-9]*[0-9.]0*\z/) ? obj.to_i : Float(obj)
+ obj = obj.to_s
47
+ if str.empty?
48
+ nil
49
+ else
50
+ # These requirements seem a bit odd, but they're explicitly specified
51
+ # in the tests, so we're obligated to keep them, for now.
52
+ str = str.chop if str.end_with?('.')
53
54
+ 0
55
56
+ result = Integer(str) rescue Float(object)
57
+ integer = result.to_i
58
+ integer == result ? integer : result
59
+ end
60
61
rescue
62
obj
63
end
0 commit comments