Class: Scrutanize::Auditor
- Inherits:
-
Object
- Object
- Scrutanize::Auditor
- Defined in:
- lib/scrutanize/auditor.rb
Instance Method Summary collapse
- #audit_error_message ⇒ Object
- #audit_errors ⇒ Object
- #log_audit_error(record) ⇒ Object
- #records_to_audit ⇒ Object
- #run ⇒ Object
- #valid_record?(record) ⇒ Boolean
Instance Method Details
#audit_error_message ⇒ Object
29 30 31 |
# File 'lib/scrutanize/auditor.rb', line 29 def fail 'audit classes must specify what the error message should be' end |
#audit_errors ⇒ Object
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_errors << record end |
#records_to_audit ⇒ Object
17 18 19 |
# File 'lib/scrutanize/auditor.rb', line 17 def records_to_audit fail 'audit classes must implement this method' end |
#run ⇒ Object
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
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 |