Class: Rack::Utils::Context
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rack-2.2.5/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.
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#for ⇒ Object
readonly
Returns the value of attribute for.
Instance Method Summary collapse
- #call(env) ⇒ Object
- #context(env, app = @app) ⇒ Object
-
#initialize(app_f, app_r) ⇒ Context
constructor
A new instance of Context.
- #recontext(app) ⇒ Object
Constructor Details
#initialize(app_f, app_r) ⇒ Context
Returns a new instance of Context.
398 399 400 401 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rack-2.2.5/lib/rack/utils.rb', line 398 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 |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
396 397 398 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rack-2.2.5/lib/rack/utils.rb', line 396 def app @app end |
#for ⇒ Object (readonly)
Returns the value of attribute for.
396 397 398 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rack-2.2.5/lib/rack/utils.rb', line 396 def for @for end |
Instance Method Details
#call(env) ⇒ Object
403 404 405 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rack-2.2.5/lib/rack/utils.rb', line 403 def call(env) @for.context(env, @app) end |
#context(env, app = @app) ⇒ Object
411 412 413 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rack-2.2.5/lib/rack/utils.rb', line 411 def context(env, app = @app) recontext(app).call(env) end |
#recontext(app) ⇒ Object
407 408 409 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rack-2.2.5/lib/rack/utils.rb', line 407 def recontext(app) self.class.new(@for, app) end |