2010-12-06 25 views
0

我查看了關於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事件引發。我怎麼做?

回答