module TrackChanges
module ActiveRecord
# 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_update TrackChanges::AroundUpdate
end
end
end
end
ActiveRecord::Base.extend TrackChanges::ActiveRecord