In a way consistent with Reactor#emit_event, wouldn't it be great if apply_event could accept a hash of event attributes? Then our aggregate mutators would be even simpler:
class Soul
include EventSourcery::Command::AggregateRoot
def sell(payload)
apply_event(type: :soul_sold, body: payload)
end
private
def apply_soul_sold(_)
end
end
Compared to the current requirements where the aggregate must instantiate an Event:
def sell(payload)
apply_event(
EventSourcery::Event.new(type: :soul_sold, body: payload)
)
end
In a way consistent with
Reactor#emit_event
, wouldn't it be great ifapply_event
could accept a hash of event attributes? Then our aggregate mutators would be even simpler:Compared to the current requirements where the aggregate must instantiate an
Event
: