Sha256: e1ef2216584b03f78a85403da0f8aeec68fd35ea611e776290d3a3e0a1ca5ad2

Contents?: true

Size: 586 Bytes

Versions: 1

Compression:

Stored size: 586 Bytes

Contents

module Economy
  class Cache

    def fetch(from, to)
      get "exchanges/#{from.iso_code.downcase}/#{to.iso_code.downcase}"
    end

    def update(exchange)
      set "exchanges/#{exchange.from.downcase}/#{exchange.to.downcase}", exchange.rate.to_s
    end

    def clear
      del 'exchanges/*'
    end

    def method_missing(name, *args, &block)
      redis.public_send name, *args, &block
    end

    private

    def redis
      @redis ||= begin
        require 'redis'
        Redis.new YAML.load_file("#{Rails.root}/config/redis.yml")[Rails.env]
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
economy-5.1.0 lib/economy/cache.rb