class FrpEventsourcing::Event

Attributes

data[R]
event_id[R]
metadata[R]

Public Class Methods

new(event_id: SecureRandom.uuid, metadata: nil, data: nil) click to toggle source
# File lib/frp-eventsourcing/event.rb, line 8
def initialize(event_id: SecureRandom.uuid, metadata: nil, data: nil)
  @event_id = event_id.to_s
  @metadata = metadata.to_h
  @data     = data.to_h
end

Public Instance Methods

==(other_event) click to toggle source
# File lib/frp-eventsourcing/event.rb, line 24
def ==(other_event)
  other_event.instance_of?(self.class) &&
    other_event.event_id.eql?(event_id) &&
    other_event.data.eql?(data)
end
Also aliased as: eql?
emit() click to toggle source
# File lib/frp-eventsourcing/event.rb, line 32
def emit
  self.class.changed
  self.class.notify_observers(self.to_h)
end
eql?(other_event)
Alias for: ==
to_h() click to toggle source
# File lib/frp-eventsourcing/event.rb, line 15
def to_h
  {
      event_id:   event_id,
      event_type: self.class,
      metadata:   metadata,
      data:       data
  }
end