Class: Rack::Cache::Tags
- Inherits:
-
Object
- Object
- Rack::Cache::Tags
- Defined in:
- lib/rack/cache/tags.rb,
lib/rack/cache/tags/store.rb,
lib/rack/cache/tags/store/active_record.rb
Defined Under Namespace
Modules: Store
Constant Summary collapse
- PURGE_TAGS_HEADER =
'rack-cache.purge-tags'
- TAGS_HEADER =
'rack-cache.tags'
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
Class Method Summary collapse
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Tags
constructor
A new instance of Tags.
Constructor Details
#initialize(app) ⇒ Tags
Returns a new instance of Tags.
24 25 26 |
# File 'lib/rack/cache/tags.rb', line 24 def initialize(app) @app = app end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
22 23 24 |
# File 'lib/rack/cache/tags.rb', line 22 def app @app end |
Class Method Details
.store ⇒ Object
10 11 12 |
# File 'lib/rack/cache/tags.rb', line 10 def store @store ||= Store::ActiveRecord.new end |
.store=(store) ⇒ Object
14 15 16 |
# File 'lib/rack/cache/tags.rb', line 14 def store=(store) @store ||= store end |
Instance Method Details
#call(env) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/rack/cache/tags.rb', line 28 def call(env) status, headers, body = app.call(env) store(Rack::Request.new(env).url, headers[TAGS_HEADER]) if status == 200 && headers.key?(TAGS_HEADER) purge(headers) if headers.key?(PURGE_TAGS_HEADER) [status, headers, body] end |