Class: Dassets::Server
- Inherits:
-
Object
- Object
- Dassets::Server
- Defined in:
- lib/dassets/server.rb,
lib/dassets/server/request.rb,
lib/dassets/server/response.rb
Defined Under Namespace
Instance Method Summary collapse
-
#call(env) ⇒ Object
The Rack call interface.
-
#call!(env) ⇒ Object
The real Rack call interface.
-
#initialize(app) ⇒ Server
constructor
A new instance of Server.
Constructor Details
#initialize(app) ⇒ Server
Returns a new instance of Server.
9 10 11 |
# File 'lib/dassets/server.rb', line 9 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
The Rack call interface. The receiver acts as a prototype and runs each request in a clone object unless the rack.run_once
variable is set in the environment. Ripped from: github.com/rtomayko/rack-cache/blob/master/lib/rack/cache/context.rb
17 18 19 20 21 22 23 |
# File 'lib/dassets/server.rb', line 17 def call(env) if env['rack.run_once'] call! env else clone.call! env end end |
#call!(env) ⇒ Object
The real Rack call interface. if an asset file is being requested, this is an endpoint - otherwise, call on up to the app as normal
28 29 30 31 32 33 34 |
# File 'lib/dassets/server.rb', line 28 def call!(env) if (request = Request.new(env)).for_asset_file? Response.new(env, request.asset_file).to_rack else @app.call(env) end end |