10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/activerecord-callback_notification.rb', line 10
def notify_callbacks!
ActiveRecord::Callbacks::CALLBACKS.each do |callback|
next if callback.to_s =~ /^around_/
next unless respond_to?(callback)
callback_meth = :"_instrument_notifications_for_#{callback}"
next if respond_to?(callback_meth)
define_method callback_meth do |&block|
ActiveSupport::Notifications.instrument("callback:#{callback}",
:object => self,
:callback => callback
)
true
end
send(callback, callback_meth)
end
end
|