Module: AuditLog::Helpers
- Defined in:
- lib/audit_log/helpers.rb
Class Method Summary collapse
-
.with_context(actor: nil, reason: nil) ⇒ Object
Sets temporary audit context (actor and reason) for the duration of the block.
Class Method Details
.with_context(actor: nil, reason: nil) ⇒ Object
Sets temporary audit context (actor and reason) for the duration of the block.
Example:
AuditLog::Helpers.with_context(actor: current_user, reason: "Batch update") do
user.update!(name: "New")
end
12 13 14 15 16 17 18 |
# File 'lib/audit_log/helpers.rb', line 12 def self.with_context(actor: nil, reason: nil) AuditLog::Context.actor = actor AuditLog::Context.reason = reason yield ensure AuditLog::Context.reset! end |