Class: BoPeep::Executor

Inherits:
Object
  • Object
show all
Defined in:
lib/bopeep.rb

Defined Under Namespace

Classes: Result

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(collection) ⇒ Executor

Returns a new instance of Executor.



1795
1796
1797
1798
# File 'lib/bopeep.rb', line 1795

def initialize(collection)
  @collection = collection
  @result = Result.new
end

Class Attribute Details

.strategiesObject (readonly)

Returns the value of attribute strategies.



1776
1777
1778
# File 'lib/bopeep.rb', line 1776

def strategies
  @strategies
end

Instance Attribute Details

#collectionObject (readonly)

Returns the value of attribute collection.



1792
1793
1794
# File 'lib/bopeep.rb', line 1792

def collection
  @collection
end

#resultObject (readonly)

Returns the value of attribute result.



1793
1794
1795
# File 'lib/bopeep.rb', line 1793

def result
  @result
end

Class Method Details

.for(name) ⇒ Object



1781
1782
1783
# File 'lib/bopeep.rb', line 1781

def self.for(name)
  @strategies.fetch(name)
end

.register(name, &block) ⇒ Object



1785
1786
1787
1788
1789
1790
# File 'lib/bopeep.rb', line 1785

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

Raises:

  • (NotImplementedError)


1806
1807
1808
# File 'lib/bopeep.rb', line 1806

def in_order(&block)
  raise NotImplementedError
end

#run(&block) ⇒ Object

FIXME: error handling?



1801
1802
1803
1804
# File 'lib/bopeep.rb', line 1801

def run(&block)
  in_order(&block)
  result
end