Module: Aggregates::MessageProcessor
- Included in:
- CommandFilter, CommandProcessor, EventProcessor
- Defined in:
- lib/aggregates/message_processor.rb
Overview
MessageProcessor is a set of helper methods for routing messages to handlers defined at the class level for DomainMessages.
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(host_class) ⇒ Object
26 27 28 |
# File 'lib/aggregates/message_processor.rb', line 26 def self.included(host_class) host_class.extend(ClassMethods) end |
Instance Method Details
#find_message_handlers(message, &block) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/aggregates/message_processor.rb', line 30 def (, &block) search_class = .class while search_class != DomainMessage handlers = self.class.[search_class] handlers&.each(&block) search_class = search_class.superclass end end |
#handle_message(message) ⇒ Object
39 40 41 42 43 |
# File 'lib/aggregates/message_processor.rb', line 39 def () .map do |handler| instance_exec(, &handler) end end |