Class: SimpleEventSourcing::Events::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_event_sourcing/events/event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Event

Returns a new instance of Event.



9
10
11
12
# File 'lib/simple_event_sourcing/events/event.rb', line 9

def initialize(args)
  @aggregate_id = args[:aggregate_id]
  @occurred_on ||= Time.now.getlocal("+02:00").to_i
end

Instance Attribute Details

#aggregate_idObject (readonly)

Returns the value of attribute aggregate_id.



7
8
9
# File 'lib/simple_event_sourcing/events/event.rb', line 7

def aggregate_id
  @aggregate_id
end

#occurred_onObject (readonly)

Returns the value of attribute occurred_on.



7
8
9
# File 'lib/simple_event_sourcing/events/event.rb', line 7

def occurred_on
  @occurred_on
end

Instance Method Details

#serializeObject



14
15
16
# File 'lib/simple_event_sourcing/events/event.rb', line 14

def serialize
  {"aggregate_id" => aggregate_id, "occurred_on" => occurred_on }
end

#to_json(*a) ⇒ Object



18
19
20
# File 'lib/simple_event_sourcing/events/event.rb', line 18

def to_json(*a)
  serialize.to_json(*a)
end