module ActiveCurrency::CacheableStore

Mixin to add caching capability to a rate store when getting the current cache.

Public Instance Methods

add_rate(from, to, rate, date = nil) click to toggle source
Calls superclass method
# File lib/active_currency/cacheable_store.rb, line 15
def add_rate(from, to, rate, date = nil)
  super

  Rails.cache.delete(cache_key(from, to))
end
get_rate(from, to, date = nil) click to toggle source
Calls superclass method
# File lib/active_currency/cacheable_store.rb, line 7
def get_rate(from, to, date = nil)
  return super if date

  Rails.cache.fetch(cache_key(from, to)) do
    super
  end
end

Private Instance Methods

cache_key(from, to) click to toggle source
# File lib/active_currency/cacheable_store.rb, line 23
def cache_key(from, to)
  ['active_currency_rate', from, to]
end