Module: EventSourcing::Application

Defined in:
lib/event_sourcing/application.rb,
lib/event_sourcing/application/actor.rb,
lib/event_sourcing/application/actor/reference.rb

Defined Under Namespace

Classes: Actor

Class Method Summary collapse

Class Method Details

.new(name) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/event_sourcing/application.rb', line 5

def self.new(name)
  Class.new do

    @name = name

    class << self

      attr_reader :name

      def run!(options = {})
        new(Array(options[:event_store]))
      end

      def inspect
        "EventSourcing::Application(#{name})"
      end
    end
    
    def initialize(options)
      @actor = Actor.spawn!(name: self.class.name, args: options)
    end

    def shutdown
      @actor.terminate!
    end

    def execute_command(command)
      @actor.execute_command(command)
    end
  end
end