Class: CallbackSequencer

Inherits:
Object
  • Object
show all
Defined in:
lib/callback-batch.rb

Overview

Sequencer for running batches upon single object.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target) ⇒ CallbackSequencer

Constructor.

Parameters:

  • target (Object)

    target object



31
32
33
34
# File 'lib/callback-batch.rb', line 31

def initialize(target)
    @batch = CallbackBatch::new
    @target = target
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object

Handles missing method calls. Puts them to the processing batch.

Parameters:

  • name (Symbol)

    name of the method

  • *args (Array)

    arguments



44
45
46
# File 'lib/callback-batch.rb', line 44

def method_missing(name, *args)
    @batch.put(@target, name, args)
end

Instance Attribute Details

#batchEM::Batch

Holds the batch object.

Returns:

  • (EM::Batch)


15
16
17
# File 'lib/callback-batch.rb', line 15

def batch
  @batch
end

#targetObject

Holds the target object.

Returns:

  • (Object)


23
24
25
# File 'lib/callback-batch.rb', line 23

def target
  @target
end

Instance Method Details

#execute(&callback) ⇒ Object Also known as: execute!

Executes the batch.

Parameters:

  • callback (Proc)


53
54
55
# File 'lib/callback-batch.rb', line 53

def execute(&callback)
    @batch.execute(&callback)
end

#resultsArray

Returns all calls results.

Returns:

  • (Array)


64
65
66
# File 'lib/callback-batch.rb', line 64

def results
    @batch.results
end