Module: Dscf::Core::AuditableModel

Extended by:
ActiveSupport::Concern
Defined in:
app/models/concerns/dscf/core/auditable_model.rb

Instance Method Summary collapse

Instance Method Details

#audit_history(limit: 50) ⇒ Object



25
26
27
# File 'app/models/concerns/dscf/core/auditable_model.rb', line 25

def audit_history(limit: 50)
  audit_logs.order(created_at: :desc).limit(limit)
end

#last_auditObject



29
30
31
# File 'app/models/concerns/dscf/core/auditable_model.rb', line 29

def last_audit
  audit_logs.order(created_at: :desc).first
end

#record_audit!(action_name, audited_changes: {}, metadata: {}, actor: nil, request_uuid: nil, ip_address: nil, user_agent: nil) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'app/models/concerns/dscf/core/auditable_model.rb', line 13

def record_audit!(action_name, audited_changes: {}, metadata: {}, actor: nil, request_uuid: nil, ip_address: nil, user_agent: nil)
  audit_logs.create!(
    action: action_name,
    audited_changes: audited_changes.presence || {},
    metadata: .presence || {},
    actor: actor,
    request_uuid: request_uuid,
    ip_address: ip_address,
    user_agent: user_agent
  )
end