mirror of
https://github.com/kemko/liquid.git
synced 2026-01-01 15:55:40 +03:00
Suppress warning: BigDecimal.new is deprecated
## Summary `BigDecimal.new` is deprecated since BigDecimal 1.3.3 for Ruby 2.5. This PR suppresses the following warnings. ```console % ruby -v ruby 2.6.0dev (2018-09-06 trunk 64648) [x86_64-darwin17] % RUBYOPT=-w bundle exec rake (snip) /Users/koic/src/github.com/Shopify/liquid/lib/liquid/utils.rb:49: warning: BigDecimal.new is deprecated; use Kernel.BigDecimal method instead. /Users/koic/src/github.com/Shopify/liquid/lib/liquid/utils.rb:53: warning: BigDecimal.new is deprecated; use Kernel.BigDecimal method instead. ``` ## Other Information The following is a change of BigDecimal 1.3.3 for Ruby 2.5 related to this PR. -533737338d-16738ad0ac
This commit is contained in:
@@ -46,11 +46,11 @@ module Liquid
|
||||
def self.to_number(obj)
|
||||
case obj
|
||||
when Float
|
||||
BigDecimal.new(obj.to_s)
|
||||
BigDecimal(obj.to_s)
|
||||
when Numeric
|
||||
obj
|
||||
when String
|
||||
(obj.strip =~ /\A-?\d+\.\d+\z/) ? BigDecimal.new(obj) : obj.to_i
|
||||
(obj.strip =~ /\A-?\d+\.\d+\z/) ? BigDecimal(obj) : obj.to_i
|
||||
else
|
||||
if obj.respond_to?(:to_number)
|
||||
obj.to_number
|
||||
|
||||
Reference in New Issue
Block a user