Class: Rack::Conditional
- Inherits:
-
Object
- Object
- Rack::Conditional
- Defined in:
- lib/rack/conditional.rb,
lib/rack/conditional/version.rb
Overview
Conditional wrapper for Rack middleware.
Constant Summary collapse
- VERSION =
'0.3.4'.freeze
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, condition, middleware, *args, &block) ⇒ Conditional
constructor
A new instance of Conditional.
Constructor Details
#initialize(app, condition, middleware, *args, &block) ⇒ Conditional
Returns a new instance of Conditional.
6 7 8 9 10 |
# File 'lib/rack/conditional.rb', line 6 def initialize(app, condition, middleware, *args, &block) @app = app @condition = condition @middleware = middleware.new(app, *args, &block) end |
Instance Method Details
#call(env) ⇒ Object
12 13 14 15 |
# File 'lib/rack/conditional.rb', line 12 def call(env) app = @condition.call(env) ? @middleware : @app app.call(env) end |