Class: Warg::Executor
- Inherits:
-
Object
- Object
- Warg::Executor
- Defined in:
- lib/warg.rb
Defined Under Namespace
Classes: Result
Class Attribute Summary collapse
-
.strategies ⇒ Object
readonly
Returns the value of attribute strategies.
Instance Attribute Summary collapse
-
#collection ⇒ Object
readonly
Returns the value of attribute collection.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Class Method Summary collapse
Instance Method Summary collapse
- #in_order(&block) ⇒ Object
-
#initialize(collection) ⇒ Executor
constructor
A new instance of Executor.
-
#run(&block) ⇒ Object
FIXME: error handling?.
Constructor Details
#initialize(collection) ⇒ Executor
Returns a new instance of Executor.
1580 1581 1582 1583 |
# File 'lib/warg.rb', line 1580 def initialize(collection) @collection = collection @result = Result.new end |
Class Attribute Details
.strategies ⇒ Object (readonly)
Returns the value of attribute strategies.
1561 1562 1563 |
# File 'lib/warg.rb', line 1561 def strategies @strategies end |
Instance Attribute Details
#collection ⇒ Object (readonly)
Returns the value of attribute collection.
1577 1578 1579 |
# File 'lib/warg.rb', line 1577 def collection @collection end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
1578 1579 1580 |
# File 'lib/warg.rb', line 1578 def result @result end |
Class Method Details
.for(name) ⇒ Object
1566 1567 1568 |
# File 'lib/warg.rb', line 1566 def self.for(name) @strategies.fetch(name) end |
.register(name, &block) ⇒ Object
1570 1571 1572 1573 1574 1575 |
# File 'lib/warg.rb', line 1570 def self.register(name, &block) strategy = Class.new(self) strategy.send(:define_method, :in_order, &block) @strategies[name] = strategy end |
Instance Method Details
#in_order(&block) ⇒ Object
1591 1592 1593 |
# File 'lib/warg.rb', line 1591 def in_order(&block) raise NotImplementedError end |
#run(&block) ⇒ Object
FIXME: error handling?
1586 1587 1588 1589 |
# File 'lib/warg.rb', line 1586 def run(&block) in_order(&block) result end |