Skip to content

Commit

Permalink
Document json_library configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
kipcole9 committed May 6, 2019
1 parent f4eea90 commit 2b9b6a7
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ An optional callback module can also be defined. This module defines a `rates_r
json_library: Cldr.Config.json_library(),
default_cldr_backend: MyApp.Cldr

**Note** that `ex_money` does not define a json library dependency and therefore it is the users responsibility to configure a required json library as a dependency in the applications `mix.exs`.

### Configuration key definitions

* `:exchange_rates_retrieve_every` defines how often the exchange rates are retrieved in milliseconds. The default is `:never`. An `atom` value is interpreted to mean that there should be no periodic retrieval.
Expand All @@ -86,10 +84,30 @@ An optional callback module can also be defined. This module defines a `rates_r

* `:retriever_options` is available for exchange rate retriever module developers as a place to add retriever-specific configuration information. This information should be added in the `init/1` callback in the retriever module. See `Money.ExchangeRates.OpenExchangeRates.init/1` for an example.

* `:json_library` determines which json library to be used for decoding. Two common options are `Poison` and `Jason`. The default is `Cldr.Config.json_library/0` which is currently configured by default as Poison.
* `:json_library` determines which json library to be used for decoding. Two common options are `Poison` and `Jason`. The default is `Cldr.Config.json_library/0` which is currently configured by default as `Jason`.

* `:default_cldr_backend` defines the `Cldr` backend module that is default for `Money`. See the [ex_cldr documentation](https://hexdocs.pm/ex_cldr/2.0.0/readme.html) for further information on how to define this module. **This is a required option**.

### JSON library configuration

Note that `ex_money` does not define a json library dependency and therefore it is the users responsibility to configure the required json library as a dependency in the application's `mix.exs`.

The recommended library is [jason](https://hex.pm/packages/jason) which would be configured as:
```
defp deps do
[
{:jason, "~> 1.0"},
...
]
end
```
`ex_money` depends on `ex_cldr` which provides currency and localisation data. The default configuration of `ex_money` uses the default `json_library` from `ex_cldr`. This can be configured as follows in `config.exs`:
```
config :ex_cldr,
json_library: Jason
```
In most cases this is not required since the presence of `Jason` (or `Poison`) is automatic.

### Configuring locales to support localised formatting

`Money` uses [ex_cldr](https://hex.pm/packages/ex_cldr) and [ex_cldr_numbers](https://hex.pm/packages/ex_cldr_numbers) to support configuring locales and providing locale formatting. These packages are also the source of currency definitions, names, formats and so on.
Expand Down

0 comments on commit 2b9b6a7

Please sign in to comment.