Class: Locomotive::Steam::Middlewares::Cache
- Inherits:
-
Object
- Object
- Locomotive::Steam::Middlewares::Cache
- Defined in:
- lib/locomotive/steam/middlewares/cache.rb
Constant Summary collapse
- CACHEABLE_REQUEST_METHODS =
%w(GET HEAD).freeze
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Cache
constructor
A new instance of Cache.
Constructor Details
#initialize(app) ⇒ Cache
Returns a new instance of Cache.
11 12 13 |
# File 'lib/locomotive/steam/middlewares/cache.rb', line 11 def initialize(app) @app = app end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
7 8 9 |
# File 'lib/locomotive/steam/middlewares/cache.rb', line 7 def app @app end |
Instance Method Details
#call(env) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/locomotive/steam/middlewares/cache.rb', line 15 def call(env) if cacheable?(env) fetch_cached_response(env) else app.call(env) end end |