class Money::Bank::SingleCurrency

Overview

Class to ensure client code is operating in a single currency by raising if an exchange attempts to happen.

This is useful when an application uses multiple currencies but it usually deals with only one currency at a time so any arithmetic where exchanges happen are erroneous. Using this as the default bank means that that these mistakes don't silently do the wrong thing.

Defined in:

money/bank/single_currency.cr

Instance Method Summary

Instance methods inherited from class Money::Bank

exchange(from : Money, to : Currency) : Money exchange, store : Currency::RateStore store, store=(store : Currency::RateStore) store=

Constructor methods inherited from class Money::Bank

new(store : Money::Currency::RateStore | Nil = nil) new

Class methods inherited from class Money::Bank

default_store : Currency::RateStore default_store, default_store=(default_store : Currency::RateStore) default_store=

Instance Method Detail

def exchange(from : Money, to : Currency) : Money #

Raises a DifferentCurrencyError to remove possibility of accidentally exchanging currencies.


[View source]