Class: RailsSimpleEventSourcing::Event
Instance Method Summary
collapse
#aggregate_class, #aggregate_defined?
Instance Method Details
#aggregate_state ⇒ Object
24
25
26
27
28
29
30
31
|
# File 'app/models/rails_simple_event_sourcing/event.rb', line 24
def aggregate_state
return unless aggregate_defined? && aggregate_id.present?
aggregate = aggregate_class.new
aggregate.id = aggregate_id
EventPlayer.new(aggregate).replay_stream(up_to_version: version)
aggregate.attributes
end
|
#apply(aggregate) ⇒ Object
18
19
20
21
22
|
# File 'app/models/rails_simple_event_sourcing/event.rb', line 18
def apply(aggregate)
payload.each do |key, value|
aggregate.send("#{key}=", value) if aggregate.respond_to?("#{key}=")
end
end
|