Module: StandardAudit::Auditable

Extended by:
ActiveSupport::Concern
Defined in:
lib/standard_audit/auditable.rb

Instance Method Summary collapse

Instance Method Details

#audit_logsObject



13
14
15
16
# File 'lib/standard_audit/auditable.rb', line 13

def audit_logs
  gid = to_global_id.to_s
  StandardAudit::AuditLog.where("actor_gid = ? OR target_gid = ?", gid, gid)
end

#audit_logs_as_actorObject



5
6
7
# File 'lib/standard_audit/auditable.rb', line 5

def audit_logs_as_actor
  StandardAudit::AuditLog.for_actor(self)
end

#audit_logs_as_targetObject



9
10
11
# File 'lib/standard_audit/auditable.rb', line 9

def audit_logs_as_target
  StandardAudit::AuditLog.for_target(self)
end

#record_audit(event_type, target: nil, scope: nil, metadata: {}, **options) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/standard_audit/auditable.rb', line 18

def record_audit(event_type, target: nil, scope: nil, metadata: {}, **options)
  StandardAudit.record(
    event_type,
    actor: self,
    target: target,
    scope: scope,
    metadata: ,
    **options
  )
end