Sha256: 56b90178a7ff25ab1c26165ffee759128c83ba8bc7980674bffbbea17b6b7bbd

Contents?: true

Size: 1.21 KB

Versions: 12

Compression:

Stored size: 1.21 KB

Contents

module EventSourcery
  module EventProcessing
    class EventStreamProcessorRegistry
      def initialize
        @processors = []
      end

      # Register the class of the Event Stream Processor.
      #
      # @param klass [Class] the class to register
      def register(klass)
        @processors << klass
      end

      # Find a registered processor by its name.
      #
      # @param processor_name [String] name of the processor you're looking for
      #
      # @return [ESProcess, nil] the found processor object or nil
      def find(processor_name)
        @processors.find do |processor|
          processor.processor_name == processor_name
        end
      end

      # Find a registered processor by its type.
      #
      # @param constant [String] name of the constant the processor has included
      #
      # @return [ESProcess, nil] the found processor object or nil
      def by_type(constant)
        @processors.select do |processor|
          processor.included_modules.include?(constant)
        end
      end

      # Returns an array of all the registered processors.
      #
      # @return [Array] of all the processors that are registered
      def all
        @processors
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
event_sourcery-1.0.0 lib/event_sourcery/event_processing/event_stream_processor_registry.rb
event_sourcery-0.24.0 lib/event_sourcery/event_processing/event_stream_processor_registry.rb
event_sourcery-0.23.1 lib/event_sourcery/event_processing/event_stream_processor_registry.rb
event_sourcery-0.23.0 lib/event_sourcery/event_processing/event_stream_processor_registry.rb
event_sourcery-0.22.0 lib/event_sourcery/event_processing/event_stream_processor_registry.rb
event_sourcery-0.21.0 lib/event_sourcery/event_processing/event_stream_processor_registry.rb
event_sourcery-0.20.0 lib/event_sourcery/event_processing/event_stream_processor_registry.rb
event_sourcery-0.19.0 lib/event_sourcery/event_processing/event_stream_processor_registry.rb
event_sourcery-0.18.0 lib/event_sourcery/event_processing/event_stream_processor_registry.rb
event_sourcery-0.17.0 lib/event_sourcery/event_processing/event_stream_processor_registry.rb
event_sourcery-0.16.1 lib/event_sourcery/event_processing/event_stream_processor_registry.rb
event_sourcery-0.15.0 lib/event_sourcery/event_processing/event_stream_processor_registry.rb