Class: Aggro::EventProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/aggro/event_proxy.rb

Overview

Private: Used as a proxy to apply and save events to an aggregate.

Instance Method Summary collapse

Constructor Details

#initialize(aggregate, id) ⇒ EventProxy

Returns a new instance of EventProxy.



4
5
6
7
# File 'lib/aggro/event_proxy.rb', line 4

def initialize(aggregate, id)
  @aggregate = aggregate
  @id = id
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_sym, *args) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/aggro/event_proxy.rb', line 9

def method_missing(method_sym, *args)
  details = merge_details_with_command_context(args.pop || {})
  event = Event.new(method_sym, Time.now, details)

  Aggro.store.write_single @id, event
  Aggro.event_bus.publish @id, event
end