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.



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

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

Class Attribute Details

.strategiesObject (readonly)

Returns the value of attribute strategies.



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

def strategies
  @strategies
end

Instance Attribute Details

#collectionObject (readonly)

Returns the value of attribute collection.



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

def collection
  @collection
end

#resultObject (readonly)

Returns the value of attribute result.



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

def result
  @result
end

Class Method Details

.for(name) ⇒ Object



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

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

.register(name, &block) ⇒ Object



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

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)


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

def in_order(&block)
  raise NotImplementedError
end

#run(&block) ⇒ Object

FIXME: error handling?



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

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