aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorChris Fung <aergonaut@gmail.com>2018-10-22 14:53:40 -0700
committerChris Fung <aergonaut@gmail.com>2018-10-22 14:53:40 -0700
commit7b67a751efe3bb9796ee64872421efffe88d31de (patch)
treec8fcf73ea4b9bec1812180ba809ec14073c10d98 /activesupport
parent9e04563ae0c488d056861965400874f6102e14f1 (diff)
downloadrails-7b67a751efe3bb9796ee64872421efffe88d31de.tar.gz
rails-7b67a751efe3bb9796ee64872421efffe88d31de.tar.bz2
rails-7b67a751efe3bb9796ee64872421efffe88d31de.zip
Add docs to ActiveSupport::Notifications.subscribe
[ci skip]
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/notifications.rb18
1 files changed, 18 insertions, 0 deletions
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