Module: Mint
- Includes:
- ActiveSupport::Configurable
- Defined in:
- lib/minting/railties.rb,
lib/minting/money_attribute/version.rb,
lib/minting/money_attribute/money_type.rb,
lib/minting/money_attribute/configuration.rb,
lib/minting/money_attribute/money_attribute.rb,
lib/generators/minting/initializer_generator.rb
Defined Under Namespace
Modules: Generators, MoneyAttribute
Classes: MintMoneyType, Railtie
Class Method Summary
collapse
Class Method Details
.assert_valid_currency!(currency) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/minting/money_attribute/configuration.rb', line 6
def self.assert_valid_currency!(currency)
if currency.is_a? Mint::Currency
code = currency.code
else
code = currency.to_s
currency = Mint.currency(code)
end
return currency if valid_currency_codes.include?(code)
raise ArgumentError,
"Invalid currency '#{code}'. Please select a registered currency: #{valid_currency_codes}"
end
|
.default_currency ⇒ Object
19
20
21
|
# File 'lib/minting/money_attribute/configuration.rb', line 19
def self.default_currency
@default_currency ||= Mint.assert_valid_currency!(config.default_currency)
end
|
.valid_currency_codes ⇒ Object
23
24
25
|
# File 'lib/minting/money_attribute/configuration.rb', line 23
def self.valid_currency_codes
config.enabled_currencies == :all ? Mint.currencies.keys : config.enabled_currencies
end
|