class SimpleEventSourcing::Events::StoredEvent

Attributes

aggregate_id[R]
event_data[R]
event_type[R]
occurred_on[R]

Public Class Methods

create_from_json(json) click to toggle source
# File lib/simple_event_sourcing/events/stored_event.rb, line 20
def self.create_from_json(json)

  stored_event_hash = JSON.parse(json)

  self.new(
    aggregate_id: stored_event_hash['aggregate_id'],
    occurred_on: stored_event_hash['occurred_on'],
    event_type: stored_event_hash['event_type'],
    event_data: stored_event_hash['event_data']
  )

end
new(args) click to toggle source
# File lib/simple_event_sourcing/events/stored_event.rb, line 9
def initialize(args)
  @aggregate_id = args[:aggregate_id]
  @occurred_on = args[:occurred_on]
  @event_type = args[:event_type]
  @event_data = args[:event_data]
end

Public Instance Methods

to_json(*a) click to toggle source
# File lib/simple_event_sourcing/events/stored_event.rb, line 16
def to_json(*a)
  {"aggregate_id" => @aggregate_id, "occurred_on" => @occurred_on.to_i, "event_type" => @event_type.to_s, "event_data" => @event_data }.to_json(*a)
end