Class: GarageClient::Cachers::Base
- Inherits:
-
Object
- Object
- GarageClient::Cachers::Base
- Defined in:
- lib/garage_client/cachers/base.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(env) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(env) ⇒ Base
Returns a new instance of Base.
5 6 7 |
# File 'lib/garage_client/cachers/base.rb', line 5 def initialize(env) @env = env end |
Instance Method Details
#call ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/garage_client/cachers/base.rb', line 9 def call response = store.read(key, ) if read_from_cache? if response # Faraday::Response#marshal_dump is drop request object and url # https://github.com/lostisland/faraday/blob/edacd5eb57ea13accab3097649690ae5f48f421a/lib/faraday/response.rb#L74 # # XXX: We can't use #merge! here because Faraday::Env does not implement # the method as same as Hash#merge! with Faraday v0.12.1. @env.each do |k, v| original = response.env[k] response.env[k] = v if !original && v end else response = yield store.write(key, response, ) if written_to_cache? end response end |