Module: Mint::Registry
- Defined in:
- lib/minting/mint/currency_store.rb
Overview
Internal currency registry 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.
16 17 18 |
# File 'lib/minting/mint/currency_store.rb', line 16 def currencies @currencies ||= Mint.world_currencies.dup 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.
24 25 26 27 28 29 30 31 |
# File 'lib/minting/mint/currency_store.rb', line 24 def 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.
37 38 39 |
# File 'lib/minting/mint/currency_store.rb', line 37 def invalidate_symbols_cache @currency_symbols = nil end |