Persistent-term-backed store for custom currencies.
Custom currencies are currencies defined with Money.Currency.new/2,
either at runtime or declaratively through the :custom_currencies
application configuration. They are stored in :persistent_term for
fast concurrent read access.
This module is started as part of the Money application supervision
tree. Currencies declared in :custom_currencies are registered each
time the store starts, so they are restored automatically after a
supervisor restart; currencies added at runtime with
Money.Currency.new/2 are not.
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.