lib/audited/auditor.rb in audited-4.2.0 vs lib/audited/auditor.rb in audited-4.2.1

- old
+ new

@@ -37,15 +37,14 @@ def audited(options = {}) # don't allow multiple calls return if self.included_modules.include?(Audited::Auditor::AuditedInstanceMethods) class_attribute :non_audited_columns, :instance_writer => false - class_attribute :auditing_enabled, :instance_writer => false class_attribute :audit_associated_with, :instance_writer => false if options[:only] - except = self.column_names - options[:only].flatten.map(&:to_s) + except = self.column_names - Array(options[:only]).flatten.map(&:to_s) else except = default_ignored_attributes + Audited.ignored_attributes except |= Array(options[:except]).collect(&:to_s) if options[:except] end self.non_audited_columns = except @@ -222,10 +221,18 @@ end def empty_callback #:nodoc: end + def auditing_enabled + self.class.auditing_enabled + end + + def auditing_enabled= val + self.class.auditing_enabled = val + end + end # InstanceMethods module AuditedClassMethods # Returns an array of columns that are audited. See non_audited_columns def audited_columns @@ -258,9 +265,17 @@ # made by +user+. This is not model specific, the method is a # convenience wrapper around # @see Audit#as_user. def audit_as( user, &block ) Audited.audit_class.as_user( user, &block ) + end + + def auditing_enabled + Audited.store.fetch("#{name.tableize}_auditing_enabled", true) + end + + def auditing_enabled= val + Audited.store["#{name.tableize}_auditing_enabled"] = val end end end end