Class: Seams::Events::Adapters::ActiveSupport

Inherits:
Seams::Events::Adapter show all
Defined in:
lib/seams/events/adapters/active_support.rb

Overview

Default in-process adapter, backed by ActiveSupport::Notifications. Suitable for monolithic deployments — every engine in the host app shares the same process, so subscribers fire synchronously after the publisher’s call returns.

Instance Method Summary collapse

Instance Method Details

#publish(event_name, payload) ⇒ Object



16
17
18
19
# File 'lib/seams/events/adapters/active_support.rb', line 16

def publish(event_name, payload)
  payload = { payload: payload } unless payload.is_a?(Hash)
  ::ActiveSupport::Notifications.instrument(event_name, payload)
end

#subscribe(event_name) ⇒ Object



21
22
23
# File 'lib/seams/events/adapters/active_support.rb', line 21

def subscribe(event_name, &)
  ::ActiveSupport::Notifications.subscribe(event_name, &)
end

#unsubscribe(subscriber) ⇒ Object



25
26
27
# File 'lib/seams/events/adapters/active_support.rb', line 25

def unsubscribe(subscriber)
  ::ActiveSupport::Notifications.unsubscribe(subscriber)
end