Class: EventSourcing::Event::Subscriber

Inherits:
Concurrent::Actor::RestartingContext
  • Object
show all
Defined in:
lib/event_sourcing/event/subscriber.rb

Overview

TODO: Should be a plain Context?

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.subscribe_to(event, &block) ⇒ Object



6
7
8
9
# File 'lib/event_sourcing/event/subscriber.rb', line 6

def self.subscribe_to(event, &block)
  define_method "handle_#{event}", &block
  Publisher.subscribe(self, event)
end

Instance Method Details

#on_message(event) ⇒ Object



11
12
13
# File 'lib/event_sourcing/event/subscriber.rb', line 11

def on_message(event)
  send("handle_#{event}", event)
end