我查看了關於ActiveSupport::Notifications
的文檔,但我對如何使用它有點不清楚。這就是我現在所擁有的:如何處理ActiveSupport :: Notifications事件?
class Foo
...
def xyz
# other stuff
ActiveSupport::Notifications.instrument(:interesting)
expensive_operation(123, 'apple') # We want to instrument this.
end
end
end
我希望做的是有另一個類,Auditor
,調用puts "event #{event}"
每當interesting
事件引發。我怎麼做?