Class: Helpstation::Processors::ParallelProcessor
- Inherits:
-
Helpstation::Processor
- Object
- Evaluator
- Helpstation::Processor
- Helpstation::Processors::ParallelProcessor
- Defined in:
- lib/helpstation/processors.rb
Overview
Helps to run processors in parallel
All output from the processors are merged and then returned. This means that if two fetchers return results with the same key then one will overwrite the other.
Class Method Summary collapse
Instance Method Summary collapse
- #call(request) ⇒ Object
-
#initialize(processors) ⇒ ParallelProcessor
constructor
A new instance of ParallelProcessor.
Methods inherited from Helpstation::Processor
Methods inherited from Evaluator
Constructor Details
#initialize(processors) ⇒ ParallelProcessor
Returns a new instance of ParallelProcessor.
20 21 22 |
# File 'lib/helpstation/processors.rb', line 20 def initialize(processors) @processors = processors end |
Class Method Details
.[](*processors) ⇒ Object
16 17 18 |
# File 'lib/helpstation/processors.rb', line 16 def self.[](*processors) new(processors) end |
Instance Method Details
#call(request) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/helpstation/processors.rb', line 24 def call(request) results = process_parallel(request) if first_failure = results.detect {|result| !result.success?} first_failure else request.success(results.reduce(request.input, &method(:compose))) end end |