Class: Money::Bank::PersistentBank
- Inherits:
-
VariableExchange
- Object
- VariableExchange
- Money::Bank::PersistentBank
- Defined in:
- lib/money/bank/persistent_bank.rb
Instance Attribute Summary collapse
-
#storage ⇒ Object
readonly
Returns the value of attribute storage.
Instance Method Summary collapse
- #clear ⇒ Object
- #export_rates ⇒ Object
- #import_rates ⇒ Object
-
#initialize(storage, key = 'persistent_bank/rates', format = :yaml) ⇒ PersistentBank
constructor
A new instance of PersistentBank.
Constructor Details
#initialize(storage, key = 'persistent_bank/rates', format = :yaml) ⇒ PersistentBank
Returns a new instance of PersistentBank.
8 9 10 11 12 13 |
# File 'lib/money/bank/persistent_bank.rb', line 8 def initialize storage, key = 'persistent_bank/rates', format = :yaml super() @storage = storage @storage_key = key @storage_format = format end |
Instance Attribute Details
#storage ⇒ Object (readonly)
Returns the value of attribute storage.
6 7 8 |
# File 'lib/money/bank/persistent_bank.rb', line 6 def storage @storage end |
Instance Method Details
#clear ⇒ Object
25 26 27 |
# File 'lib/money/bank/persistent_bank.rb', line 25 def clear storage.delete(@storage_key) end |
#export_rates ⇒ Object
15 16 17 |
# File 'lib/money/bank/persistent_bank.rb', line 15 def export_rates storage.write(@storage_key, super(@storage_format)) end |
#import_rates ⇒ Object
19 20 21 22 23 |
# File 'lib/money/bank/persistent_bank.rb', line 19 def import_rates rates.clear cache = storage.read(@storage_key) super(@storage_format, cache) if cache end |