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.



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

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

Class Attribute Details

.strategiesObject (readonly)

Returns the value of attribute strategies.



1561
1562
1563
# File 'lib/warg.rb', line 1561

def strategies
  @strategies
end

Instance Attribute Details

#collectionObject (readonly)

Returns the value of attribute collection.



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

def collection
  @collection
end

#resultObject (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

Raises:

  • (NotImplementedError)


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