Module: UniRateRails::Helper
- Defined in:
- lib/unirate_rails/helper.rb
Overview
Instance Method Summary collapse
-
#unirate_convert(amount, from = nil, to = nil) ⇒ Object
Convert
amountfromfromtoto(a Float), or nil on any UniRate error. -
#unirate_rate(from = nil, to = nil) ⇒ Object
Current rate from
fromtoto(a Float), or nil on any UniRate error so a rate hiccup never raises inside a view render.
Instance Method Details
#unirate_convert(amount, from = nil, to = nil) ⇒ Object
Convert amount from from to to (a Float), or nil on any UniRate
error.
22 23 24 25 26 27 |
# File 'lib/unirate_rails/helper.rb', line 22 def unirate_convert(amount, from = nil, to = nil) from ||= UniRateRails.configuration.default_currency UniRateRails.client.convert(to: to, amount: amount, from: from) rescue UniRateRails::UnirateError nil end |
#unirate_rate(from = nil, to = nil) ⇒ Object
Current rate from from to to (a Float), or nil on any UniRate error
so a rate hiccup never raises inside a view render.
13 14 15 16 17 18 |
# File 'lib/unirate_rails/helper.rb', line 13 def unirate_rate(from = nil, to = nil) from ||= UniRateRails.configuration.default_currency UniRateRails.client.get_rate(from: from, to: to) rescue UniRateRails::UnirateError nil end |