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

Class Method Details

.currenciesHash{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.

Returns:

  • (Hash{String => Currency})

    registered currencies mapped by code



16
17
18
# File 'lib/minting/mint/currency_store.rb', line 16

def currencies
  @currencies ||= Mint.world_currencies.dup
end

.currency_symbolsArray<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.

Returns:

  • (Array<Array<String, Currency>>)

    sorted symbol-to-currency mappings



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_cacheObject

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