Module: EventSourcery::EventProcessing::EventStreamProcessor::ClassMethods
- Defined in:
- lib/event_sourcery/event_processing/event_stream_processor.rb
Instance Attribute Summary collapse
- #all_event_handler ⇒ Object readonly
- #event_handlers ⇒ Object readonly
- #processes_event_types ⇒ Object readonly
Instance Method Summary collapse
-
#process(*event_classes, &block) ⇒ Object
Process the events for the given event types with the given block.
-
#processes?(event_type) ⇒ True, False
Can this class process this event type.
-
#processor_name(name = nil) ⇒ Object
Set the name of the processor.
Instance Attribute Details
#all_event_handler ⇒ Object (readonly)
44 45 46 |
# File 'lib/event_sourcery/event_processing/event_stream_processor.rb', line 44 def all_event_handler @all_event_handler end |
#event_handlers ⇒ Object (readonly)
44 45 46 |
# File 'lib/event_sourcery/event_processing/event_stream_processor.rb', line 44 def event_handlers @event_handlers end |
#processes_event_types ⇒ Object (readonly)
44 45 46 |
# File 'lib/event_sourcery/event_processing/event_stream_processor.rb', line 44 def processes_event_types @processes_event_types end |
Instance Method Details
#process(*event_classes, &block) ⇒ Object
Process the events for the given event types with the given block.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/event_sourcery/event_processing/event_stream_processor.rb', line 74 def process(*event_classes, &block) if event_classes.empty? if @all_event_handler raise MultipleCatchAllHandlersDefined, 'Attemping to define multiple catch all event handlers.' else @all_event_handler = block end else @processes_event_types ||= [] event_classes.each do |event_class| @processes_event_types << event_class.type @event_handlers[event_class.type] << block end end end |
#processes?(event_type) ⇒ True, False
Can this class process this event type.
51 52 53 54 |
# File 'lib/event_sourcery/event_processing/event_stream_processor.rb', line 51 def processes?(event_type) processes_event_types && processes_event_types.include?(event_type.to_s) end |
#processor_name(name = nil) ⇒ Object
Set the name of the processor. Returns the class name if no name is given.
60 61 62 63 64 65 66 |
# File 'lib/event_sourcery/event_processing/event_stream_processor.rb', line 60 def processor_name(name = nil) if name @processor_name = name else (defined?(@processor_name) && @processor_name) || self.name end end |