Class: Conrad::ProcessorStack Private

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/conrad/processor_stack.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Contains the main logic to share how processors are handled between the individual, one-off recorder and the collector.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(processors) ⇒ ProcessorStack

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of ProcessorStack.

Parameters:

  • processors (Array<#call>)

    set of objects all responding to #call that will be used to process an event



20
21
22
23
24
# File 'lib/conrad/processor_stack.rb', line 20

def initialize(processors)
  check_callability(processors)

  @processors = processors
end

Instance Attribute Details

#processorsObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The processors used by this Stack



12
13
14
# File 'lib/conrad/processor_stack.rb', line 12

def processors
  @processors
end

Instance Method Details

#call(event) ⇒ nil, Hash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Processes an event through the defined set of operations, returning the final hash. It is possible to ‘throw :halt_conrad_processing` to stop the processing stack. There should be no additional arguments to the `throw` call. At this point, the processing will stop and return nil.

Returns:

  • (nil, Hash)

    nil in the case that halt_conrad_processing has been caught, otherwise the result of all the processors which should be a Hash.



34
35
36
37
38
39
40
# File 'lib/conrad/processor_stack.rb', line 34

def call(event)
  catch :halt_conrad_processing do
    processors.reduce(event) do |previous_built_event, processor|
      processor.call(previous_built_event)
    end
  end
end