Sha256: 1498cb6601c8379e2683ef01c3f740a2b406211b4626ba470fcdccb164c1f7be

Contents?: true

Size: 430 Bytes

Versions: 1

Compression:

Stored size: 430 Bytes

Contents

require 'faraday'
require 'api_cache'

module FaradayAPICache
  class Middleware < Faraday::Middleware
    def initialize(app, options = {})
      super(app)
      @options = { period: 0, timeout: 0 }.merge(options.to_hash)
    end

    def call(env)
      if env[:method] == :get
        APICache.get(env[:url].to_s, @options) do
          @app.call(env)
        end
      else
        @app.call(env)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
faraday_api_cache-0.0.3 lib/faraday_api_cache/middleware.rb