Scenario: class SpecialMoney < Money # ... end SpecialMoney.new(val1) + SpecialMoney.new(val2) # => returns Money instead of SpecialMoney, thus losing the # SpecialMoney extensions.
…index from bank’s export/import. * RatesStore#each_rate returns Enumerator used by Bank’s export_data method. * RateStore::Memory mutex flag is passed on initialisation, not on every call to #add_rate and #get_rate. Defaults to thread-safe. * RateStore::Memory and Bank::VariableExchange happen to index / export data with “_TO_” separator, but these two clases should not about eachother’s internal serialisation.
Bank::VariableExchange doesn’t know anything about mutexes (that’s the Store’s job).
…::Memory. VariableExchange uses that store by default. This allows us to swap the storage mechanism (i.e. Redis, memcache, database, file, etc) without losing the behaviour in VariableExchange, or having to subclass or re-implement it. Composition > Inheritance. RatesStore::Memory only deals in currency iso codes: type checking and coercing stops at the bank. Removed testing of private #rate_key_for method. Todo: * do not test instance variables! (@mutex). Find a better way to test thread-safety. * move thread-safety tests to store tests. Bank doesn’t need to know about it.
A special circumstance for #== to recognize that the value of 0 money will also equal 0 in any other currency.