Skip to content

Commit

Permalink
Return just territory code mapped to current currency code
Browse files Browse the repository at this point in the history
  • Loading branch information
kipcole9 committed Jan 27, 2023
1 parent 3471453 commit 75413d8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
4 changes: 2 additions & 2 deletions lib/cldr/backend.ex
Original file line number Diff line number Diff line change
Expand Up @@ -610,9 +610,9 @@ defmodule Cldr.Currency.Backend do
"""
@doc since: "2.15.0"

@spec current_territory_currencies() :: %{Cldr.Locale.territory_code() => Cldr.Currency.t()}
@spec current_territory_currencies() :: %{Cldr.Locale.territory_code() => Cldr.Currency.code()}
def current_territory_currencies do
Cldr.Currency.current_territory_currencies(unquote(backend))
Cldr.Currency.current_territory_currencies()
end

@doc """
Expand Down
16 changes: 5 additions & 11 deletions lib/cldr/currency.ex
Original file line number Diff line number Diff line change
Expand Up @@ -765,20 +765,15 @@ defmodule Cldr.Currency do
Antartica, territory code `:AQ`) then no
mapping is returned for that territory.
## Arguments
* `backend` is any module that includes `use Cldr` and therefore
is a `Cldr` backend module. The default is `Cldr.default_backend!/0`
## Returns
* A map of `{territory_code => Cldr.Currency.t}`
* A map of `{territory_code => currency.code}`
"""
@doc since: "2.15.0"

@spec current_territory_currencies() :: %{Cldr.Locale.territory_code() => t()}
def current_territory_currencies(backend \\ Cldr.default_backend!()) do
@spec current_territory_currencies() :: %{Cldr.Locale.territory_code() => code()}
def current_territory_currencies do
territory_currencies()
|> Enum.map(fn
{:ZZ, _currencies} ->
Expand All @@ -787,7 +782,7 @@ defmodule Cldr.Currency do
{territory, _currencies} ->
case current_currency_for_territory(territory) do
nil -> {territory, nil}
currency -> {territory, currency_for_code!(currency, backend)}
currency -> {territory, currency}
end
end)
|> Enum.reject(fn
Expand Down Expand Up @@ -1703,8 +1698,7 @@ defmodule Cldr.Currency do

defimpl Cldr.DisplayName do
def display_name(currency, options) do
{:ok, display_name} = Cldr.Currency.display_name(currency, options)
display_name
Cldr.Currency.display_name!(currency, options)
end
end
end

0 comments on commit 75413d8

Please sign in to comment.