Class: Rigger::ExecutionStrategy::Selector
- Inherits:
-
Object
- Object
- Rigger::ExecutionStrategy::Selector
- Defined in:
- lib/rigger/execution_strategy.rb
Instance Method Summary collapse
- #call(task) ⇒ Object
-
#initialize(basic_strategy = BasicExecutionStrategy.new, strategies = [SerialExecutionStrategy.new, SingleExecutionStrategy.new]) ⇒ Selector
constructor
A new instance of Selector.
Constructor Details
#initialize(basic_strategy = BasicExecutionStrategy.new, strategies = [SerialExecutionStrategy.new, SingleExecutionStrategy.new]) ⇒ Selector
Returns a new instance of Selector.
36 37 38 39 40 41 |
# File 'lib/rigger/execution_strategy.rb', line 36 def initialize(basic_strategy = BasicExecutionStrategy.new, strategies = [SerialExecutionStrategy.new, SingleExecutionStrategy.new]) @basic_strategy = basic_strategy @strategies = strategies end |
Instance Method Details
#call(task) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/rigger/execution_strategy.rb', line 43 def call(task) appropriate_strategies = @strategies.select do |s| s.appropriate_strategy_for?(task) end if appropriate_strategies.length > 1 raise MultipleAppropriateStrategies, "More than one strategy was appropriate for #{task.name}." else appropriate_strategies.first || @basic_strategy end end |