Class: RulesEngine::Process::DbAuditor

Inherits:
Auditor
  • Object
show all
Defined in:
lib/rules_engine/process/auditor/db_auditor.rb

Instance Attribute Summary

Attributes inherited from Auditor

#audit_level

Instance Method Summary collapse

Methods inherited from Auditor

#perform_audit?

Constructor Details

#initialize(*options) ⇒ DbAuditor

Returns a new instance of DbAuditor.



20
21
# File 'lib/rules_engine/process/auditor/db_auditor.rb', line 20

def initialize(*options)        
end

Instance Method Details

#audit(process_id, message, code = RulesEngine::Process::AUDIT_INFO) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/rules_engine/process/auditor/db_auditor.rb', line 23

def audit(process_id, message, code = RulesEngine::Process::AUDIT_INFO)
  super
  if perform_audit?(code)
    # $stderr.puts("#{'*' * 5} #{process_id}, #{code}, #{message}")
    ReProcessAudit.create({
      :process_id => process_id,
      :created_at => Time.now,  
      :code => code,
      :message => message});
  end  
end

#history(process_id, options = {}) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/rules_engine/process/auditor/db_auditor.rb', line 35

def history(process_id, options ={})
  re_process_audits = ReProcessAudit.history(process_id, options)
  {
    "audits" => re_process_audits.map do |re_process_audit| 
      {
        "process_id" => re_process_audit.process_id, 
        "created_at" => re_process_audit.created_at.utc.to_s, 
        "code" => re_process_audit.code, 
        "message" => re_process_audit.message
      }
    end
  }                          
end