abstract class Money::Currency::RateStore

Included Modules

Direct Known Subclasses

Defined in:

money/currency/rate_store.cr

Instance Method Summary

Instance Method Detail

def [](from : String | Symbol | Currency, to : String | Symbol | Currency) : BigDecimal #

Retrieve the rate for the given currency pair.

store = Money::Currency::RateStore::Memory.new
store["USD", "CAD"] = 1.24515
store["USD", "CAD"]? # => 1.24515

[View source]
def []=(from : String | Symbol | Currency, to : String | Symbol | Currency, value : Number) : Nil #

Registers a conversion rate and returns it.

store = Money::Currency::RateStore::Memory.new
store["USD", "CAD"] = 1.24515
store["CAD", "USD"] = 0.803115

[View source]
def []?(from : String | Symbol | Currency, to : String | Symbol | Currency) : BigDecimal | Nil #

Retrieve the rate for the given currency pair.

store = Money::Currency::RateStore::Memory.new
store["USD", "CAD"] = 1.24515
store["USD", "CAD"]? # => 1.24515

[View source]
def clear : Nil #

Empties currency rate index.


[View source]
def each(& : Rate -> _) : Nil #

Iterates over list of Rate objects.

store.each do |rate|
  puts rate
end

[View source]
abstract def transaction(& : -> _) #

Wraps block execution in a concurrency-safe transaction.


[View source]