Class: Rack::Reducer::Middleware
- Inherits:
-
Object
- Object
- Rack::Reducer::Middleware
- Defined in:
- lib/rack/reducer/middleware.rb
Overview
Mount Rack::Reducer as middleware
Instance Method Summary collapse
-
#call(env) ⇒ Object
Call the next app in the middleware stack, with env set to the ouput of a reduction.
-
#initialize(app, options = {}) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app, options = {}) ⇒ Middleware
Returns a new instance of Middleware.
8 9 10 11 12 |
# File 'lib/rack/reducer/middleware.rb', line 8 def initialize(app, = {}) @app = app @key = [:key] || 'rack.reduction' @props = end |
Instance Method Details
#call(env) ⇒ Object
Call the next app in the middleware stack, with env set to the ouput of a reduction
16 17 18 19 20 |
# File 'lib/rack/reducer/middleware.rb', line 16 def call(env) params = Rack::Request.new(env).params reduction = Reduction.new(@props.merge(params: params)).reduce @app.call env.merge(@key => reduction) end |