Class: EventSourcery::EventProcessing::EventStreamProcessorRegistry

Inherits:
Object
  • Object
show all
Defined in:
lib/event_sourcery/event_processing/event_stream_processor_registry.rb

Instance Method Summary collapse

Constructor Details

#initializeEventStreamProcessorRegistry

Returns a new instance of EventStreamProcessorRegistry.



4
5
6
# File 'lib/event_sourcery/event_processing/event_stream_processor_registry.rb', line 4

def initialize
  @processors = []
end

Instance Method Details

#allArray

Returns an array of all the registered processors.

Returns:

  • (Array)

    of all the processors that are registered



40
41
42
# File 'lib/event_sourcery/event_processing/event_stream_processor_registry.rb', line 40

def all
  @processors
end

#by_type(constant) ⇒ ESProcess?

Find a registered processor by its type.

Parameters:

  • constant (String)

    name of the constant the processor has included

Returns:

  • (ESProcess, nil)

    the found processor object or nil



31
32
33
34
35
# File 'lib/event_sourcery/event_processing/event_stream_processor_registry.rb', line 31

def by_type(constant)
  @processors.select do |processor|
    processor.included_modules.include?(constant)
  end
end

#find(processor_name) ⇒ ESProcess?

Find a registered processor by its name.

Parameters:

  • processor_name (String)

    name of the processor you’re looking for

Returns:

  • (ESProcess, nil)

    the found processor object or nil



20
21
22
23
24
# File 'lib/event_sourcery/event_processing/event_stream_processor_registry.rb', line 20

def find(processor_name)
  @processors.find do |processor|
    processor.processor_name == processor_name
  end
end

#register(klass) ⇒ Object

Register the class of the Event Stream Processor.

Parameters:

  • klass (Class)

    the class to register



11
12
13
# File 'lib/event_sourcery/event_processing/event_stream_processor_registry.rb', line 11

def register(klass)
  @processors << klass
end