Class: Warg::Executor

Inherits:
Object
  • Object
show all
Defined in:
lib/warg.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.



1670
1671
1672
1673
# File 'lib/warg.rb', line 1670

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

Class Attribute Details

.strategiesObject (readonly)

Returns the value of attribute strategies.



1651
1652
1653
# File 'lib/warg.rb', line 1651

def strategies
  @strategies
end

Instance Attribute Details

#collectionObject (readonly)

Returns the value of attribute collection.



1667
1668
1669
# File 'lib/warg.rb', line 1667

def collection
  @collection
end

#resultObject (readonly)

Returns the value of attribute result.



1668
1669
1670
# File 'lib/warg.rb', line 1668

def result
  @result
end

Class Method Details

.for(name) ⇒ Object



1656
1657
1658
# File 'lib/warg.rb', line 1656

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

.register(name, &block) ⇒ Object



1660
1661
1662
1663
1664
1665
# File 'lib/warg.rb', line 1660

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)


1681
1682
1683
# File 'lib/warg.rb', line 1681

def in_order(&block)
  raise NotImplementedError
end

#run(&block) ⇒ Object

FIXME: error handling?



1676
1677
1678
1679
# File 'lib/warg.rb', line 1676

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