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.
11 12 13 |
# File 'lib/dassets/server.rb', line 11 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
19 20 21 22 23 24 25 |
# File 'lib/dassets/server.rb', line 19 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
30 31 32 33 34 35 36 |
# File 'lib/dassets/server.rb', line 30 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 |