abstract class Money::Currency::RateStore
- Money::Currency::RateStore
- Reference
- Object
Included Modules
- Enumerable(Money::Currency::Rate)
Direct Known Subclasses
Defined in:
money/currency/rate_store.crInstance Method Summary
-
#[](from, to) : BigDecimal
Retrieve the rate for the given currencies.
-
#[]=(from, to, value : Number) : Nil
Registers a conversion rate and returns it.
-
#[]?(from, to) : BigDecimal | Nil
Retrieve the rate for the given currencies.
-
#add_rate(from : Currency, to : Currency, value : Int64) : Nil
See
#[]=
. -
#clear : Nil
Empties currency rate index.
-
#clear_rates : Nil
See
#clear
. -
#each(&block : T -> _)
Iterates over list of
Rate
objects. -
#get_rate?(from : Currency, to : Currency) : Rate | Nil
See
#[]?
. -
#transaction(&block : -> _)
Wraps block execution in a concurrency-safe transaction.
Instance Method Detail
def [](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
def []=(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
def []?(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
See #[]=
.
Iterates over list of Rate
objects.
store.each do |rate|
puts rate
end