Class Rack::Utils::Context
In: lib/rack/utils.rb
Parent: Proc

The recommended manner in which to implement a contexting application is to define a method context in which a new Context is instantiated.

As a Context is a glorified block, it is highly recommended that you define the contextual block within the application‘s operational scope. This would typically the application as you‘re place into Rack‘s stack.

  class MyObject
    ...
    def context app
      Rack::Utils::Context.new app do |env|
        do_stuff
        response = app.call(env)
        do_more_stuff
      end
    end
    ...
  end

mobj = MyObject.new app = mobj.context other_app Rack::Handler::Mongrel.new app

Methods

context   inspect   new   pretty_print  

External Aliases

inspect -> old_inspect

Attributes

app  [R] 
for  [R] 

Public Class methods

[Source]

     # File lib/rack/utils.rb, line 129
129:       def initialize app_f, app_r
130:         raise 'running context not provided' unless app_f
131:         raise 'running context does not respond to #context' unless app_f.respond_to? :context
132:         raise 'application context not provided' unless app_r
133:         raise 'application context does not respond to #call' unless app_r.respond_to? :call
134:         @for = app_f
135:         @app = app_r
136:       end

Public Instance methods

[Source]

     # File lib/rack/utils.rb, line 140
140:       def context app_r
141:         raise 'new application context not provided' unless app_r
142:         raise 'new application context does not respond to #call' unless app_r.respond_to? :call
143:         @for.context app_r
144:       end

[Source]

     # File lib/rack/utils.rb, line 137
137:       def inspect
138:         "#{old_inspect} ==> #{@for.inspect} ==> #{@app.inspect}"
139:       end

[Source]

     # File lib/rack/utils.rb, line 145
145:       def pretty_print pp
146:         pp.text old_inspect
147:         pp.nest 1 do
148:           pp.breakable
149:           pp.text '=for> '
150:           pp.pp @for
151:           pp.breakable
152:           pp.text '=app> '
153:           pp.pp @app
154:         end
155:       end

[Validate]