Skip to content

Instantly share code, notes, and snippets.

@rubish
rubish / publisher.rb
Last active October 1, 2019 08:26
Pub/Sub using ActiveSupport::Notifications
module Publisher
extend self
def broadcast_event(event_name, payload={})
if block_given?
ActiveSupport::Notifications.instrument(event_name, payload) do
yield
end
else
ActiveSupport::Notifications.instrument(event_name, payload)