From d5f8486d3f861f9848f4cd919fcdc33fe9f43dca Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Fri, 21 Dec 2018 10:28:06 +0900 Subject: Use BigDecimal provided methods to convert String to BigDecimal `String#to_d` does not raise an exception if an invalid value is specified. So can remove exception handling. ``` $ bundle exec ruby -v -rbigdecimal -rbigdecimal/util -e 'p "123,003".to_d' ruby 2.6.0dev (2018-12-21 trunk 66474) [x86_64-linux] 0.123e3 ``` --- activesupport/lib/active_support/xml_mini.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'activesupport/lib/active_support') diff --git a/activesupport/lib/active_support/xml_mini.rb b/activesupport/lib/active_support/xml_mini.rb index be298bf0a1..b5995d6fe9 100644 --- a/activesupport/lib/active_support/xml_mini.rb +++ b/activesupport/lib/active_support/xml_mini.rb @@ -68,11 +68,7 @@ module ActiveSupport "float" => Proc.new { |float| float.to_f }, "decimal" => Proc.new do |number| if String === number - begin - BigDecimal(number) - rescue ArgumentError - BigDecimal(number.to_f.to_s) - end + number.to_d else BigDecimal(number) end -- cgit v1.2.3