I want to be notified when certain things happen in some of my classes. I want to configure this so that the implementation of my methods in these classes does not change.
I thought I would have something like the following module:
module Notifications
extend ActiveSupport::Concern
module ClassMethods
def notify_when(method)
puts "the #{method} method was called!"
end
end
end
Then I can mix it with my classes as follows:
class Foo
include Notifications
notify_when :bar
def bar(...)
end
end
My key desire is that I do not want to change :barin order to receive notifications correctly. It can be done? If so, how can I write an implementation notify_when?
I also use Rails 3, so if there are ActiveSupport or other methods that I can use, feel free to share them. (I looked at ActiveSupport :: Notifications , but that will require me to change the method bar.)
, " + ". , - , - ?