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

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



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_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



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



38
39
40
# File 'lib/minting/mint/currency_store.rb', line 38

def self.invalidate_symbols_cache
  @currency_symbols = nil
end