module Sequent::Core::SerializesEvent

Public Class Methods

included(host_class) click to toggle source
# File lib/sequent/core/event_record.rb, line 70
def self.included(host_class)
  host_class.extend(ClassMethods)
end

Public Instance Methods

event() click to toggle source
# File lib/sequent/core/event_record.rb, line 48
def event
  payload = Sequent::Core::Oj.strict_load(event_json)
  Class.const_get(event_type).deserialize_from_json(payload)
end
event=(event) click to toggle source
# File lib/sequent/core/event_record.rb, line 53
def event=(event)
  self.aggregate_id = event.aggregate_id
  self.sequence_number = event.sequence_number
  self.organization_id = event.organization_id if event.respond_to?(:organization_id)
  self.event_type = event.class.name
  self.created_at = event.created_at
  self.event_json = self.class.serialize_to_json(event)

  Sequent.configuration.event_record_hooks_class.after_serialization(self, event)
end