mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Keep AS::XmlMini::PARSING["decimal"].call('') returning 0
BigDecimal('an invalid string') has changed its behavior to raise an ArgumentError since 1.3.0 https://bugs.ruby-lang.org/issues/10286
This commit is contained in:
parent
414484f68d
commit
b87619f945
1 changed files with 11 additions and 1 deletions
|
@ -68,7 +68,17 @@ module ActiveSupport
|
|||
"datetime" => Proc.new { |time| Time.xmlschema(time).utc rescue ::DateTime.parse(time).utc },
|
||||
"integer" => Proc.new { |integer| integer.to_i },
|
||||
"float" => Proc.new { |float| float.to_f },
|
||||
"decimal" => Proc.new { |number| BigDecimal(number) },
|
||||
"decimal" => Proc.new do |number|
|
||||
if String === number
|
||||
begin
|
||||
BigDecimal(number)
|
||||
rescue ArgumentError
|
||||
BigDecimal('0')
|
||||
end
|
||||
else
|
||||
BigDecimal(number)
|
||||
end
|
||||
end,
|
||||
"boolean" => Proc.new { |boolean| %w(1 true).include?(boolean.to_s.strip) },
|
||||
"string" => Proc.new { |string| string.to_s },
|
||||
"yaml" => Proc.new { |yaml| YAML::load(yaml) rescue yaml },
|
||||
|
|
Loading…
Reference in a new issue