module TrackChanges
module ActiveRecord #:nodoc:
def self.included(base)
base.send :extend, ClassMethods
end
module ClassMethods
# Enables auditing of all changes to an ActiveRecord model. Sets up an
# around filter that will create an Audit for the models changes
# attribute.
#
# In addition, this will also define a attr_accessor for current_user.
def track_changes
send :include, TrackChanges::CurrentUser
send :include, TrackChanges::Changes
self.class_eval do
has_many :audits, :as => :audited
around_save TrackChanges::AroundSave
end
end
end
end
end