Class: EventSourcing::Application::Actor

Inherits:
Concurrent::Actor::RestartingContext
  • Object
show all
Defined in:
lib/event_sourcing/application/actor.rb,
lib/event_sourcing/application/actor/reference.rb

Defined Under Namespace

Classes: Reference

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(event_store) ⇒ Actor

Returns a new instance of Actor.



19
20
21
22
23
24
# File 'lib/event_sourcing/application/actor.rb', line 19

def initialize(event_store)
  @event_store = event_store
  @event_bus   = EventSourcing::Event::Bus.spawn!(name: :event_bus, supervise: true, args: [@event_store])
  @aggregate_manager = EventSourcing::Aggregate::Manager.spawn!(name: :aggregate_manager, supervise: true, args: [@event_bus])
  @command_bus = EventSourcing::Command::Bus.spawn!(name: :command_bus, supervise: true, args: [@aggregate_manager])
end

Class Method Details

.to_strObject

TODO Remove this. It’s needed for specs passing under jruby O_o



11
12
13
# File 'lib/event_sourcing/application/actor.rb', line 11

def self.to_str #TODO Remove this. It's needed for specs passing under jruby O_o
  to_s 
end

Instance Method Details

#default_reference_classObject



15
16
17
# File 'lib/event_sourcing/application/actor.rb', line 15

def default_reference_class
  Reference
end

#on_message(message) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/event_sourcing/application/actor.rb', line 26

def on_message(message)
  case message
  when :get_command_bus
    @command_bus
  when :get_event_bus
    @event_bus
  when :get_aggregate_manager
    @aggregate_manager
  end
end