Class: Rack::Utils::Context
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/rack/utils.rb |
Overview
Context
allows the use of a compatible middleware at different points in a request handling stack. A compatible middleware must define #context which should take the arguments env and app. The first of which would be the request environment. The second of which would be the rack application that the request would be forwarded to.
Class Method Summary
- .call(env) mod_func
- .context(env, app = @app) mod_func
- .initialize(app_f, app_r) mod_func
- .recontext(app) mod_func
- .new(app_f, app_r) constructor private
Constructor Details
.new(app_f, app_r) (private)
[ GitHub ]# File 'lib/rack/utils.rb', line 457
def initialize(app_f, app_r) raise 'running context does not respond to #context' unless app_f.respond_to? :context @for, @app = app_f, app_r end
Class Method Details
.call(env) (mod_func)
[ GitHub ]# File 'lib/rack/utils.rb', line 462
def call(env) @for.context(env, @app) end
.context(env, app = @app) (mod_func)
[ GitHub ].initialize(app_f, app_r) (mod_func)
[ GitHub ]# File 'lib/rack/utils.rb', line 457
def initialize(app_f, app_r) raise 'running context does not respond to #context' unless app_f.respond_to? :context @for, @app = app_f, app_r end
.recontext(app) (mod_func)
[ GitHub ]# File 'lib/rack/utils.rb', line 466
def recontext(app) self.class.new(@for, app) end