Class: SimpleEventSourcing::Events::Event
- Inherits:
-
Object
- Object
- SimpleEventSourcing::Events::Event
- Defined in:
- lib/simple_event_sourcing/events/event.rb
Instance Attribute Summary collapse
-
#aggregate_id ⇒ Object
readonly
Returns the value of attribute aggregate_id.
-
#occurred_on ⇒ Object
readonly
Returns the value of attribute occurred_on.
Instance Method Summary collapse
-
#initialize(args) ⇒ Event
constructor
A new instance of Event.
- #serialize ⇒ Object
- #to_json(*a) ⇒ Object
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_id ⇒ Object (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_on ⇒ Object (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
#serialize ⇒ Object
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 |