Class: Helpstation::Processors::ConditionalProcessor
- Inherits:
-
Helpstation::Processor
- Object
- Evaluator
- Helpstation::Processor
- Helpstation::Processors::ConditionalProcessor
- Defined in:
- lib/helpstation/processors.rb
Overview
Helps to run one chain or another depending on a request
Class Method Summary collapse
Methods inherited from Helpstation::Processor
Methods inherited from Evaluator
Constructor Details
This class inherits a constructor from Helpstation::Evaluator
Class Method Details
.[](condition, success_chain, fallback_chain) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/helpstation/processors.rb', line 65 def self.[](condition, success_chain, fallback_chain) Proc.new do |request| result = if condition.call(request) success_chain.call(request) else fallback_chain.call(request) end if result.is_a?(Substation::Response) result else request.success(result.input) end end end |