From 5124d7eab260bdf4c79e098f67bad7a5c82d6d5c Mon Sep 17 00:00:00 2001 From: owen2345 Date: Thu, 24 Jun 2021 08:36:56 -0400 Subject: [PATCH] feat: fix bigdecimal deprecation for rails 6 --- lib/king_dta/booking.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/king_dta/booking.rb b/lib/king_dta/booking.rb index b6bfcea..9e91f67 100644 --- a/lib/king_dta/booking.rb +++ b/lib/king_dta/booking.rb @@ -24,9 +24,9 @@ def initialize( account, value, text=nil, account_key=nil, currency="EUR" ) end @currency = currency if value.is_a?(String) - value = BigDecimal.new value.sub(',', '.') + value = big_decimal value.sub(',', '.') elsif value.is_a?(Numeric) - value = BigDecimal.new value.to_s + value = big_decimal value.to_s else raise Exception.new("Gimme a value as a String or Numeric. You gave me a #{value.class}") end @@ -46,6 +46,10 @@ def text=(text) @text = convert_text( text ) end + def big_decimal(val) + BigDecimal.try(:new, val) || BigDecimal(val) + end + def pos?; @pos end end #class Buchung