diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2018-10-23 01:15:44 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-23 01:15:44 -0400 |
commit | 05db669c5cbf7835dae56348b98a9eef46405ea2 (patch) | |
tree | bc0d1a84408b7d86b9c5a35d853a392cc5830d6b /activesupport/lib | |
parent | 802f374af1baf035eb84bb3e60783aab359da198 (diff) | |
parent | 7b67a751efe3bb9796ee64872421efffe88d31de (diff) | |
download | rails-05db669c5cbf7835dae56348b98a9eef46405ea2.tar.gz rails-05db669c5cbf7835dae56348b98a9eef46405ea2.tar.bz2 rails-05db669c5cbf7835dae56348b98a9eef46405ea2.zip |
Merge pull request #34290 from aergonaut/docs/ActiveSupport--Notifications-subscribe
Add docs to ActiveSupport::Notifications.subscribe
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/notifications.rb | 18 |
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 |