Module: RivetCms::Audit

Defined in:
lib/rivet_cms/audit.rb

Class Method Summary collapse

Class Method Details

.record(action, subject:, actor:, organization:, metadata: {}) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/rivet_cms/audit.rb', line 20

def record(action, subject:, actor:, organization:, metadata: {})
  event = AuditEvent.new(
    action: action.to_s,
    subject_type: subject.class.name.demodulize.underscore,
    subject_id: subject.try(:prefix_id) || subject.id,
    subject_label: label_for(subject),
    organization_id: organization&.id,
    actor: actor,
    metadata: ,
    at: Time.current
  )
  Hooks.run(:audit, event)
  event
end