Class: Sinatra::CacheAssets
- Inherits:
-
Object
- Object
- Sinatra::CacheAssets
- Defined in:
- lib/sinatra/cache_assets.rb
Constant Summary collapse
- VERSION =
"0.0.3"
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ CacheAssets
constructor
A new instance of CacheAssets.
Constructor Details
#initialize(app, options = {}) ⇒ CacheAssets
Returns a new instance of CacheAssets.
8 9 10 11 |
# File 'lib/sinatra/cache_assets.rb', line 8 def initialize(app, ={}) @app = app @options = end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
6 7 8 |
# File 'lib/sinatra/cache_assets.rb', line 6 def app @app end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/sinatra/cache_assets.rb', line 6 def @options end |
Instance Method Details
#call(env) ⇒ Object
13 14 15 16 17 |
# File 'lib/sinatra/cache_assets.rb', line 13 def call(env) code, headers, body = app.call(env) headers["Cache-Control"] = "public, max-age=#{duration}" if env['sinatra.static_file'] [ code, headers, body ] end |