class Item < ActiveRecord::Base
def active=(value)
self.set_old('active', self.active)
write_attribute(:active, value)
end
def after_update
if !get_old('active') and self.active
# notify activated...
end
if get_old('active') != self.active
# delete caches...
end
end
protected
def get_old(value)
@old[value] unless @old.nil?
end
def set_old(key, value)
(@old ||= {})[key] = value
end
end