module Auditable::Auditor::InstanceMethods
Private Instance Methods
audit_changes(*args)
click to toggle source
# File lib/auditable/auditor.rb, line 54 def audit_changes(*args) self.audited_attribute_changes = changes.dup # Delete keys we don't want to moderate anyway. self.audited_attribute_changes.delete_if{ |k,v| [:id, :updated_at, :created_at].include?(k.to_sym) } # Delete changes that were nil but are now blank. # This is useful for when optional fields of new records are saved wtih no content. self.audited_attribute_changes.delete_if{ |k,v| v == [nil,'']} # If no attributes are supplied then the entire record is moderated otherwise moderate only the supplied columns. unless self.class.base_class.audited_attributes.empty? self.audited_attribute_changes.delete_if{ |k,v| !self.class.base_class.audited_attributes.include?(k.to_sym) } end AuditRecord.create_for(self) end