Class: Warg::Executor

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

Defined Under Namespace

Classes: Deferred, 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.



1590
1591
1592
1593
# File 'lib/warg.rb', line 1590

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

Class Attribute Details

.strategiesObject (readonly)

Returns the value of attribute strategies.



1571
1572
1573
# File 'lib/warg.rb', line 1571

def strategies
  @strategies
end

Instance Attribute Details

#collectionObject (readonly)

Returns the value of attribute collection.



1587
1588
1589
# File 'lib/warg.rb', line 1587

def collection
  @collection
end

#resultObject (readonly)

Returns the value of attribute result.



1588
1589
1590
# File 'lib/warg.rb', line 1588

def result
  @result
end

Class Method Details

.for(name) ⇒ Object



1576
1577
1578
# File 'lib/warg.rb', line 1576

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

.register(name, &block) ⇒ Object



1580
1581
1582
1583
1584
1585
# File 'lib/warg.rb', line 1580

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)


1601
1602
1603
# File 'lib/warg.rb', line 1601

def in_order(&block)
  raise NotImplementedError
end

#run(&block) ⇒ Object

FIXME: error handling?



1596
1597
1598
1599
# File 'lib/warg.rb', line 1596

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