class Sequent::Core::EventRecordHooks

Event Record Hooks

These hooks are called during the life cycle of Sequent::Core::EventRecord. It is recommended to create a subclass of Sequent::Core::EventRecordHooks when implementing this in your application.

Sequent.configure do |config|
  config.event_record_hooks_class = MyApp::EventRecordHooks
end

module MyApp
  class EventRecordHooks < Sequent::EventRecordHooks

    # Adds additional metadata to the +event_records+ table.
    def self.after_serialization(event_record, event)
      event_record.metadata = event.metadata if event.respond_to?(:metadata)
    end

  end
end

Public Class Methods

after_serialization(event_record, event) click to toggle source

Called after assigning Sequent’s event attributes to the event_record.

Params

  • event_record An instance of Sequent.configuration.event_record_class

  • event An instance of the Sequent::Core::Event being persisted

    class EventRecordHooks < Sequent::EventRecordHooks
      def self.after_serialization(event_record, event)
        event_record.seen_by_hook = true
      end
    end
    
# File lib/sequent/core/event_record.rb, line 42
def self.after_serialization(event_record, event)
  # noop
end