5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'app/jobs/standard_audit/create_audit_log_job.rb', line 5
def perform(attrs)
attrs = attrs.symbolize_keys
actor_gid = attrs.delete(:actor_gid)
target_gid = attrs.delete(:target_gid)
scope_gid = attrs.delete(:scope_gid)
actor_type = attrs.delete(:actor_type)
target_type = attrs.delete(:target_type)
scope_type = attrs.delete(:scope_type)
log = StandardAudit::AuditLog.new(attrs)
if actor_gid.present?
begin
log.actor = GlobalID::Locator.locate(actor_gid)
rescue ActiveRecord::RecordNotFound
log.actor_gid = actor_gid
log.actor_type = actor_type
end
end
if target_gid.present?
begin
log.target = GlobalID::Locator.locate(target_gid)
rescue ActiveRecord::RecordNotFound
log.target_gid = target_gid
log.target_type = target_type
end
end
if scope_gid.present?
begin
log.scope = GlobalID::Locator.locate(scope_gid)
rescue ActiveRecord::RecordNotFound
log.scope_gid = scope_gid
log.scope_type = scope_type
end
end
log.save!
end
|