class Money::Currency::RateStore::Memory
- Money::Currency::RateStore::Memory
- Money::Currency::RateStore
- Reference
- Object
Overview
Class for concurrency-safe storage of exchange rate pairs.
Used by instances of Currency::VariableExchange
.
store = Money::Currency::RateStore::Memory.new
store["USD", "CAD"] = 0.98
store["USD", "CAD"] # => 0.98
# Iterates rates
store.each do |rate|
puts rate
end
Defined in:
money/currency/rate_store/memory.crConstant Summary
-
INDEX_KEY_SEPARATOR =
'_'
Constructors
-
.new
Initializes a new
RateStore::Memory
object.
Instance Method Summary
-
#each(&)
Iterates over list of
Rate
objects. -
#transaction(& : -> _)
Wraps block execution in a thread-safe transaction.
Instance methods inherited from class Money::Currency::RateStore
[](from, to) : BigDecimal
[],
[]=(from, to, value : Number) : Nil
[]=,
[]?(from, to) : BigDecimal | Nil
[]?,
add_rate(from : Currency, to : Currency, value : Int64) : Nil
add_rate,
clear : Nil
clear,
clear_rates : Nil
clear_rates,
each(&block : T -> _)
each,
get_rate?(from : Currency, to : Currency) : Rate | Nil
get_rate?,
transaction(&block : -> _)
transaction
Constructor Detail
Instance Method Detail
def each(&)
#
Description copied from class Money::Currency::RateStore
Iterates over list of Rate
objects.
store.each do |rate|
puts rate
end
def transaction(& : -> _)
#
Wraps block execution in a thread-safe transaction.
NOTE Uses Mutex
to synchronize data access.