From 3e16a91f22fdab0e4eaad1539f6accced2c52b3c Mon Sep 17 00:00:00 2001 From: Lud Date: Tue, 18 Jul 2023 18:12:36 +0200 Subject: [PATCH] OXR bank uses nilable Floats :vomit: --- lib/money/distributed/storage.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/money/distributed/storage.rb b/lib/money/distributed/storage.rb index d4407d0..08f1883 100644 --- a/lib/money/distributed/storage.rb +++ b/lib/money/distributed/storage.rb @@ -30,10 +30,13 @@ def initialize(redis, cache_ttl = nil) params( iso_from: String, iso_to: String, - rate: BigDecimal, + rate: T.nilable(Numeric), ).void end def add_rate(iso_from, iso_to, rate) + # other gems, e.g. "money-open-exchange-rates", may return nil and use Float + return if rate.nil? + @redis.exec do |r| r.hset(REDIS_KEY, key_for(iso_from, iso_to), rate.to_s) end