Я посмотрел документацию для 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
.Как мне это сделать?