Persistent-term-backed store for custom currencies.
Custom currencies are currencies defined at runtime using
Money.Currency.new/2. They are stored in :persistent_term
for fast concurrent read access.
This module is started as part of the Money application supervision tree.
Summary
Functions
Returns all custom currencies as a map of %{currency_code => currency_struct}.
Returns a specification to start this module under a supervisor.
Returns a list of all custom currency codes.
Returns the custom currency for the given code, or nil.
Stores a custom currency.
Starts the custom currency store.
Functions
@spec all() :: %{required(atom()) => Localize.Currency.t()}
Returns all custom currencies as a map of %{currency_code => currency_struct}.
Returns
- A map of custom currencies. Returns an empty map if no custom currencies have been defined.
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec codes() :: [atom()]
Returns a list of all custom currency codes.
Returns
- A list of atom currency codes.
@spec get(atom()) :: Localize.Currency.t() | nil
Returns the custom currency for the given code, or nil.
Arguments
codeis a currency code atom.
Returns
- A
Localize.Currency.t/0struct ornil.
@spec put(Localize.Currency.t()) :: {:ok, Localize.Currency.t()} | {:error, Exception.t()}
Stores a custom currency.
Arguments
currencyis aLocalize.Currency.t/0struct.
Returns
{:ok, currency}on success.{:error, Money.CurrencyNotSavedError.t()}if the store is not running.
Starts the custom currency store.