class

Money::Currency::RateStore

Inherits Enumerable / Reference / Object

Instance methods

[](from, to) : BigDecimal

Retrieve the rate for the given currencies. NOTE: Uses transaction to synchronize data access.

store = Money::Currency::RateStore::Memory.new
store["USD", "CAD"] = 1.24515
store["USD", "CAD"]? # => 1.24515
Source
[]=(from, to, value : Number) : Nil

Registers a conversion rate and returns it. NOTE: Uses transaction to synchronize data access.

store = Money::Currency::RateStore::Memory.new
store["USD", "CAD"] = 1.24515
store["CAD", "USD"] = 0.803115
Source
[]?(from, to) : BigDecimal | Nil

Retrieve the rate for the given currencies. NOTE: Uses transaction to synchronize data access.

store = Money::Currency::RateStore::Memory.new
store["USD", "CAD"] = 1.24515
store["USD", "CAD"]? # => 1.24515
Source
add_rate(from : Currency, to : Currency, value : Int64) : Nil

See #[]=.

Source
clear

Empties currency rate index. NOTE: Uses transaction to synchronize data access.

Source
clear_rates

See #clear.

Source
each

Iterates over list of Rate objects.

store.each do |rate|
  puts rate
end
Source
get_rate?(from : Currency, to : Currency) : Rate | Nil

See #[]?.

Source
transaction

Wraps block execution in a concurrency-safe transaction.

Source

Nested types