class AuditedAsync::AuditAsyncJob
Public Instance Methods
perform(args)
click to toggle source
# File lib/audited_async/audit_async_job.rb, line 6 def perform(args) klass, id, changes = extract_auditing_elements(args) record = klass.unscoped.find_by(klass.primary_key.to_sym => id) return alert_record_not_found(klass, id) unless record record.send(:write_audit, changes) end
Private Instance Methods
alert_record_not_found(klass, id)
click to toggle source
# File lib/audited_async/audit_async_job.rb, line 26 def alert_record_not_found(klass, id) AuditedAsync.logger.error "AuditedAsync: #{klass} record with id '#{id}' not found, ignoring audit write." end
extract_audit_changes(args)
click to toggle source
# File lib/audited_async/audit_async_job.rb, line 22 def extract_audit_changes(args) args.except(:class_name, :record_id).merge(audited_changes: JSON.parse(args[:audited_changes])) end
extract_auditing_elements(args)
click to toggle source
# File lib/audited_async/audit_async_job.rb, line 18 def extract_auditing_elements(args) return [args[:class_name].safe_constantize, args[:record_id], extract_audit_changes(args)] end