Class: Rack::PactBroker::UseWhen::ConditionallyUseMiddleware
- Inherits:
-
Object
- Object
- Rack::PactBroker::UseWhen::ConditionallyUseMiddleware
- Defined in:
- lib/rack/pact_broker/use_when.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, condition_proc, middleware, *args, **kwargs, &block) ⇒ ConditionallyUseMiddleware
constructor
A new instance of ConditionallyUseMiddleware.
Constructor Details
#initialize(app, condition_proc, middleware, *args, **kwargs, &block) ⇒ ConditionallyUseMiddleware
Returns a new instance of ConditionallyUseMiddleware.
18 19 20 21 22 23 24 25 |
# File 'lib/rack/pact_broker/use_when.rb', line 18 def initialize(app, condition_proc, middleware, *args, **kwargs, &block) @app_without_middleware = app @condition_proc = condition_proc @middleware = middleware @args = args @kwargs = kwargs @block = block end |
Instance Method Details
#call(env) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/rack/pact_broker/use_when.rb', line 27 def call(env) if condition_proc.call(env) app_with_middleware.call(env) else app_without_middleware.call(env) end end |