From 7b67a751efe3bb9796ee64872421efffe88d31de Mon Sep 17 00:00:00 2001 From: Chris Fung Date: Mon, 22 Oct 2018 14:53:40 -0700 Subject: Add docs to ActiveSupport::Notifications.subscribe [ci skip] --- activesupport/lib/active_support/notifications.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/notifications.rb b/activesupport/lib/active_support/notifications.rb index 2d8b9c5d86..01cc363e2b 100644 --- a/activesupport/lib/active_support/notifications.rb +++ b/activesupport/lib/active_support/notifications.rb @@ -171,6 +171,24 @@ module ActiveSupport end end + # Subscribe to a given event name with the passed +block+. + # + # You can subscribe to events by passing a String to match exact event + # names, or by passing a Regexp to match all events that match a pattern. + # + # ActiveSupport::Notifications.subscribe(/render/) do |*args| + # ... + # end + # + # The +block+ will receive five parameters with information about the event: + # + # ActiveSupport::Notifications.subscribe('render') do |name, start, finish, id, payload| + # name # => String, name of the event (such as 'render' from above) + # start # => Time, when the instrumented block started execution + # finish # => Time, when the instrumented block ended execution + # id # => String, unique ID for the instrumenter that fired the event + # payload # => Hash, the payload + # end def subscribe(*args, &block) notifier.subscribe(*args, &block) end -- cgit v1.2.3