Class: Scrutanize::Auditor

Inherits:
Object
  • Object
show all
Defined in:
lib/scrutanize/auditor.rb

Instance Method Summary collapse

Instance Method Details

#audit_error_messageObject



29
30
31
# File 'lib/scrutanize/auditor.rb', line 29

def audit_error_message
  fail 'audit classes must specify what the error message should be'
end

#audit_errorsObject



25
26
27
# File 'lib/scrutanize/auditor.rb', line 25

def audit_errors
  @errors ||= []
end

#log_audit_error(record) ⇒ Object



12
13
14
15
# File 'lib/scrutanize/auditor.rb', line 12

def log_audit_error(record)
  Scrutanize::AuditLog.create(audit_type: record.class.to_s, message: audit_error_message)
  audit_errors << record
end

#records_to_auditObject



17
18
19
# File 'lib/scrutanize/auditor.rb', line 17

def records_to_audit
  fail 'audit classes must implement this method'
end

#runObject



3
4
5
6
7
8
9
10
# File 'lib/scrutanize/auditor.rb', line 3

def run
  records_to_audit.each do |record|
    unless valid_record?(record)
      log_audit_error(record)
    end
  end
  audit_errors
end

#valid_record?(record) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/scrutanize/auditor.rb', line 21

def valid_record?(record)
  fail 'audit classes must specify how to validate the record'
end