Module: EventSorcerer::EventApplicator

Defined in:
lib/event_sorcerer/event_applicator.rb

Overview

Public: Helper for applying events to an aggregate.

Class Method Summary collapse

Class Method Details

.apply_event!(aggregate, event) ⇒ Object

Public: Sets the clock to the event time and calls the event method on

the aggregate.

aggregate - The Aggregate to apply the Event to. event - The Event to be applied.

Returns self.



14
15
16
17
18
19
20
# File 'lib/event_sorcerer/event_applicator.rb', line 14

def self.apply_event!(aggregate, event)
  EventSorcerer.with_time(event.created_at) do
    Invokr.invoke method: event.name, on: aggregate, using: event.details
  end

  self
end