Class: Sinatra::CacheAssets

Inherits:
Object
  • Object
show all
Defined in:
lib/sinatra/cache_assets.rb

Constant Summary collapse

VERSION =
"0.0.3"

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options={})
  @app = app
  @options = options
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



6
7
8
# File 'lib/sinatra/cache_assets.rb', line 6

def app
  @app
end

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/sinatra/cache_assets.rb', line 6

def options
  @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