Allow Utils.to_number to work with anything that responds to #to_number

This commit is contained in:
Ismael Celis
2016-03-30 01:57:21 -03:00
parent 021bafd260
commit d03c4ae8e8
2 changed files with 17 additions and 1 deletions
+5 -1
View File
@@ -52,7 +52,11 @@ module Liquid
when String
(obj.strip =~ /\A\d+\.\d+\z/) ? BigDecimal.new(obj) : obj.to_i
else
0
if obj.respond_to?(:to_number)
obj.to_number
else
0
end
end
end