Module: Mint::CurrencyStore
- Defined in:
- lib/minting/mint/currency_store.rb
Overview
Internal currency storage and loading. Manages the registry cache and currency symbol lookups.
Class Method Summary collapse
-
.currencies ⇒ Hash{String => Currency}
private
Returns the hash of all registered currencies.
-
.currency_symbols ⇒ Array<Array<String, Currency>>
private
Registered symbols sorted for detection: longest match wins, then parser priority.
-
.invalidate_symbols_cache ⇒ Object
private
Clears and refreshes the currency symbol cache.
Class Method Details
.currencies ⇒ Hash{String => Currency}
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the hash of all registered currencies.
14 15 16 17 18 19 |
# File 'lib/minting/mint/currency_store.rb', line 14 def self.currencies @currencies ||= begin registry = { 'XXX' => Currency.new(code: 'XXX', name: 'No currency', symbol: 'ยค') } load_currencies(registry) end end |
.currency_symbols ⇒ Array<Array<String, Currency>>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Registered symbols sorted for detection: longest match wins, then parser priority.
25 26 27 28 29 30 31 32 |
# File 'lib/minting/mint/currency_store.rb', line 25 def self.currency_symbols @currency_symbols ||= begin currencies.values .reject { |currency| currency.symbol.empty? } .map { |currency| [currency.symbol, currency] } .sort_by { |symbol, currency| [-symbol.length, -currency.priority] } end.freeze end |
.invalidate_symbols_cache ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Clears and refreshes the currency symbol cache. Called when currencies are registered.
38 39 40 |
# File 'lib/minting/mint/currency_store.rb', line 38 def self.invalidate_symbols_cache @currency_symbols = nil end |