class Economy::Cache
Public Instance Methods
clear()
click to toggle source
# File lib/economy/cache.rb, line 12 def clear del 'exchanges/*' end
fetch(from, to)
click to toggle source
# File lib/economy/cache.rb, line 4 def fetch(from, to) get "exchanges/#{from.iso_code.downcase}/#{to.iso_code.downcase}" end
method_missing(name, *args, &block)
click to toggle source
# File lib/economy/cache.rb, line 16 def method_missing(name, *args, &block) redis.public_send name, *args, &block end
update(exchange)
click to toggle source
# File lib/economy/cache.rb, line 8 def update(exchange) set "exchanges/#{exchange.from.downcase}/#{exchange.to.downcase}", exchange.rate.to_s end
Private Instance Methods
redis()
click to toggle source
# File lib/economy/cache.rb, line 22 def redis @redis ||= begin require 'redis' Redis.new YAML.load_file("#{Rails.root}/config/redis.yml")[Rails.env] end end