module ForeignCurrencyExchange::Money::Configuration
This module contains configuration methods for Money
class
Constants
- BASE_CURRENCY_RATE
Attributes
base_currency[R]
rates[R]
Public Instance Methods
check_configuration()
click to toggle source
# File lib/foreign_currency_exchange/money/configuration.rb, line 18 def check_configuration check_rates check_base_currency_rate end
conversion_rates(base_currency, rates)
click to toggle source
# File lib/foreign_currency_exchange/money/configuration.rb, line 9 def conversion_rates(base_currency, rates) @rates = rates @base_currency = base_currency check_configuration rescue => exception nullify_configuration raise exception end
Private Instance Methods
check_base_currency_rate()
click to toggle source
# File lib/foreign_currency_exchange/money/configuration.rb, line 34 def check_base_currency_rate raise InvalidBaseCurrencyRateError unless valid_base_currency_rate? end
check_rates()
click to toggle source
# File lib/foreign_currency_exchange/money/configuration.rb, line 30 def check_rates raise InvalidRatesError unless valid_rates? end
nullify_configuration()
click to toggle source
# File lib/foreign_currency_exchange/money/configuration.rb, line 25 def nullify_configuration @rates = nil @base_currency = nil end
valid_base_currency_rate?()
click to toggle source
# File lib/foreign_currency_exchange/money/configuration.rb, line 43 def valid_base_currency_rate? !rates.key?(base_currency) || rates[base_currency] == BASE_CURRENCY_RATE end
valid_rates?()
click to toggle source
# File lib/foreign_currency_exchange/money/configuration.rb, line 38 def valid_rates? rates.is_a?(Hash) && !rates.empty? && rates.values.all? { |v| v.is_a?(Numeric) && v.positive? } end