Class: RailsAuditLog::Streaming::ActiveJobAdapter
- Inherits:
-
Object
- Object
- RailsAuditLog::Streaming::ActiveJobAdapter
- Defined in:
- lib/rails_audit_log/streaming/active_job_adapter.rb
Overview
Publishes each audit entry asynchronously by enqueuing PublishEntryJob. The job fires a rails_audit_log.entry_created notification when performed, so subscribers receive the entry out-of-band without blocking the request.
Instance Method Summary collapse
-
#initialize(queue: nil) ⇒ ActiveJobAdapter
constructor
A new instance of ActiveJobAdapter.
- #publish(entry) ⇒ Object
Constructor Details
#initialize(queue: nil) ⇒ ActiveJobAdapter
Returns a new instance of ActiveJobAdapter.
14 15 16 |
# File 'lib/rails_audit_log/streaming/active_job_adapter.rb', line 14 def initialize(queue: nil) @queue = queue end |
Instance Method Details
#publish(entry) ⇒ Object
18 19 20 21 22 |
# File 'lib/rails_audit_log/streaming/active_job_adapter.rb', line 18 def publish(entry) job = RailsAuditLog::Streaming::PublishEntryJob job = job.set(queue: @queue) if @queue job.perform_later(entry.attributes.compact) end |