Class: Rack::Client::Cache::Request
- Inherits:
-
Request
- Object
- Request
- Rack::Client::Cache::Request
show all
- Includes:
- Options
- Defined in:
- lib/rack/client/middleware/cache/request.rb
Instance Method Summary
collapse
Methods included from Options
option_accessor, option_name, #options, #options=, #set
Instance Method Details
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/rack/client/middleware/cache/request.rb', line 16
def
@calculating_headers = true
return {} unless cacheable?
entry = metastore.lookup(self, entitystore)
if entry
(entry)
else
{}
end
ensure
@calculating_headers = nil
end
|
#cacheable? ⇒ Boolean
7
8
9
|
# File 'lib/rack/client/middleware/cache/request.rb', line 7
def cacheable?
request_method == 'GET'
end
|
#entitystore ⇒ Object
39
40
41
42
|
# File 'lib/rack/client/middleware/cache/request.rb', line 39
def entitystore
uri = options['rack-client-cache.entitystore']
storage.resolve_entitystore_uri(uri)
end
|
#env ⇒ Object
11
12
13
14
|
# File 'lib/rack/client/middleware/cache/request.rb', line 11
def env
return super if @calculating_headers
.merge(super)
end
|
30
31
32
|
# File 'lib/rack/client/middleware/cache/request.rb', line 30
def (response)
return 'HTTP_If-None-Match' => response.etag
end
|
34
35
36
37
|
# File 'lib/rack/client/middleware/cache/request.rb', line 34
def metastore
uri = options['rack-client-cache.metastore']
storage.resolve_metastore_uri(uri)
end
|