Class: RailsAuditLog::Streaming::NotificationsAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_audit_log/streaming/notifications_adapter.rb

Overview

Publishes each audit entry synchronously via ActiveSupport::Notifications. Zero external dependencies — subscribe with ActiveSupport::Notifications.subscribe.

Examples:

RailsAuditLog.streaming_adapter = RailsAuditLog::Streaming::NotificationsAdapter.new

ActiveSupport::Notifications.subscribe("rails_audit_log.entry_created") do |*, payload|
  entry = payload[:entry]
  Rails.logger.info "Audit: #{entry.event} on #{entry.item_type}##{entry.item_id}"
end

Constant Summary collapse

EVENT =
"rails_audit_log.entry_created"

Instance Method Summary collapse

Instance Method Details

#publish(entry) ⇒ Object



16
17
18
# File 'lib/rails_audit_log/streaming/notifications_adapter.rb', line 16

def publish(entry)
  ActiveSupport::Notifications.instrument(EVENT, entry: entry)
end