@@ -33,15 +33,15 @@ ActiveCurrency::AddRates.call(currencies: %w[EUR USD])
3333You can then exchange money by using the Money gem helpers:
3434
3535``` rb
36- 10 .to_money(' EUR' ).exchange_to(' USD' ).cents
36+ 10 .to_money(" EUR" ).exchange_to(" USD" ).cents
3737```
3838
3939If you need to look up the previous currency rates:
4040
4141``` rb
42- ActiveCurrency ::Rate .value_for(' EUR' , ' USD' , 1 .month.ago)
42+ ActiveCurrency ::Rate .value_for(" EUR" , " USD" , 1 .month.ago)
4343# => 1.151
44- ActiveCurrency ::Rate .where(from: ' EUR' , to: ' USD' ).pluck(:value )
44+ ActiveCurrency ::Rate .where(from: " EUR" , to: " USD" ).pluck(:value )
4545# => [1.162, 1.162, 1.161, 1.161, 1.163, …]
4646```
4747
@@ -88,7 +88,7 @@ add the following to your application’s initializers:
8888``` rb
8989ActiveCurrency .configure do |config |
9090 config.remote_bank = :open_exchange_rates
91- config.open_exchange_rates_app_id = ' … '
91+ config.open_exchange_rates_app_id = " … "
9292end
9393```
9494
@@ -101,16 +101,21 @@ You can provide any Money-compatible bank when calling
101101ActiveCurrency ::AddRates .call(…, bank: …)
102102```
103103
104- ## Apply a multiplier
105-
106- If you want to increase or decrease the currency rates by a given multiplier,
107- you can do so by setting the ` multiplier ` option:
104+ ## Configuration
108105
109106``` rb
110107ActiveCurrency .configure do |config |
111- config.multiplier = {
112- [" EUR" , " USD" ] => 1.01 ,
113- }
108+ # Use the money-open-exchange-rates bank instead.
109+ # config.remote_bank = :open_exchange_rates
110+ # config.open_exchange_rates_app_id = "…"
111+
112+ # Disable `Rails.cache`.
113+ # config.cache_enabled = false
114+
115+ # Increase or decrease the currency rates by a given multiplier.
116+ # config.multiplier = {
117+ # ["EUR", "USD"] => 1.01,
118+ # }
114119end
115120```
116121
@@ -124,8 +129,8 @@ For that, you can use a fake rate store in your `rails_helper.rb`:
124129``` rb
125130MoneyRails .configure do |config |
126131 rate_store = Money ::RatesStore ::Memory .new .tap do |store |
127- store.add_rate(' USD' , ' EUR' , 1.5 )
128- store.add_rate(' EUR' , ' USD' , 0.67 )
132+ store.add_rate(" USD" , " EUR" , 1.5 )
133+ store.add_rate(" EUR" , " USD" , 0.67 )
129134 end
130135 config.default_bank = Money ::Bank ::VariableExchange .new (rate_store)
131136end
0 commit comments