Class: Rack::Current::Middleware

Inherits:
Object
  • Object
show all
Includes:
Rack::Current
Defined in:
lib/rack-current/middleware.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Middleware

Returns a new instance of Middleware.



7
8
9
# File 'lib/rack-current/middleware.rb', line 7

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/rack-current/middleware.rb', line 11

def call(env)
  before = self.current_request
  self.current_request = Rack::Request.new(env)
  @app.call(env)
ensure
  self.current_request = before
end