Module: Audited::Auditor::AuditedInstanceMethods

Defined in:
lib/audited_async.rb

Instance Method Summary collapse

Instance Method Details

#audit_createObject



6
7
8
# File 'lib/audited_async.rb', line 6

def audit_create
  perform_async_audit 'create'
end

#audit_destroyObject



16
17
18
# File 'lib/audited_async.rb', line 16

def audit_destroy
  perform_async_audit 'destroy' unless new_record?
end

#audit_updateObject



10
11
12
13
14
# File 'lib/audited_async.rb', line 10

def audit_update
  unless (changes = audited_changes).empty? && audit_comment.blank?
    perform_async_audit 'update'
  end
end

#perform_async_audit(method) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/audited_async.rb', line 20

def perform_async_audit(method)
  AuditedAsync::AuditAsyncJob.perform_later class_name: self.class.name,
                                            record_id: send(self.class.primary_key.to_sym),
                                            action: method,
                                            audited_changes: audited_attributes.to_json,
                                            comment: audit_comment
end