Class: RulesEngine::Process::Auditor

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

Direct Known Subclasses

DbAuditor

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#audit_levelObject

Returns the value of attribute audit_level.



34
35
36
# File 'lib/rules_engine/process/auditor.rb', line 34

def audit_level
  @audit_level
end

Instance Method Details

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



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

def audit(process_id, message, code = RulesEngine::Process::AUDIT_INFO)
  if perform_audit?(code)
    if defined?(Rails) && Rails.logger 
      case code
      when RulesEngine::Process::AUDIT_FAILURE
        Rails.logger.error("#{'*' * 5} #{process_id}, #{code}, #{message}")
      else # when RulesEngine::Process::AUDIT_INFO, RulesEngine::Process::AUDIT_SUCCESS
        Rails.logger.info("#{'*' * 5} #{process_id}, #{code}, #{message}")
      end
    else  
      $stderr.puts("#{'*' * 5} #{process_id}, #{code}, #{message}")
    end
  end   
end

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



51
52
53
54
55
# File 'lib/rules_engine/process/auditor.rb', line 51

def history(process_id, options = {})
  {
    "audits" => []
  }  
end

#perform_audit?(code) ⇒ Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/rules_engine/process/auditor.rb', line 57

def perform_audit?(code)
  audit_level.nil? || (audit_level != RulesEngine::Process::AUDIT_NONE && code >= audit_level)
end