Sha256: 46469e74e7bdfe3afe08ec028dd959a31789544a10d2fbd189221c1eadfe80b4
Contents?: true
Size: 1.5 KB
Versions: 3
Compression:
Stored size: 1.5 KB
Contents
module RulesEngine module Process class ReProcessAudit < ActiveRecord::Base validates_presence_of :code scope :by_process_id, lambda {|process_id| where('process_id = ?', process_id)} scope :order_created_at, lambda {|order| order("created_at #{order}, id #{order}") } def self.history(process_id, options = {}) klass = self klass = klass.by_process_id(process_id) klass = klass.order_created_at('ASC') klass.find(:all) end end class DbAuditor < Auditor def initialize(*options) end 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 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 end end end
Version data entries
3 entries across 3 versions & 1 rubygems