class Conrad::ProcessorStack
@api private Contains the main logic to share how processors are handled between the individual, one-off recorder and the collector.
Attributes
processors[R]
The processors used by this Stack
Public Class Methods
new(processors)
click to toggle source
@param processors [Array<#call>] set of objects all responding to call
that will be used to process an event
# File lib/conrad/processor_stack.rb, line 20 def initialize(processors) check_callability(processors) @processors = processors end
Public Instance Methods
call(event)
click to toggle source
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.
@return [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.
# 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
Private Instance Methods
check_callability(processors)
click to toggle source
# File lib/conrad/processor_stack.rb, line 44 def check_callability(processors) processors.each do |processor| raise ArgumentError, "#{processor} does not respond to `#call`" unless processor.respond_to?(:call) end end