Module: Sequent::Core::Helpers::SelfApplier

Included in:
AggregateRoot, BaseCommandHandler, BaseEventHandler, Workflow
Defined in:
lib/sequent/core/helpers/self_applier.rb

Overview

Creates ability to use DSL like: class MyEventHandler < Sequent::Core::BaseEventHandler

on MyEvent do |event|
  do_some_logic
end

end

You typically do not need to include this module in your classes. If you extend from Sequent::Core::AggregateRoot, Sequent::Core::Projector, Sequent::Core::Workflow or Sequent::Core::BaseCommandHandler you will get this functionality for free.

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(host_class) ⇒ Object



33
34
35
# File 'lib/sequent/core/helpers/self_applier.rb', line 33

def self.included(host_class)
  host_class.extend(ClassMethods)
end

Instance Method Details

#handle_message(message) ⇒ Object



37
38
39
40
# File 'lib/sequent/core/helpers/self_applier.rb', line 37

def handle_message(message)
  handler = self.class.message_mapping[message.class]
  self.instance_exec(message, &handler) if handler
end