Skip to content

Commit a67fdc0

Browse files
committed
Update documentation to reflect unsubscription with name.
1 parent 02ee081 commit a67fdc0

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

activesupport/lib/active_support/notifications.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@ module ActiveSupport
141141
#
142142
# ActiveSupport::Notifications.unsubscribe(subscriber)
143143
#
144+
# You can also unsubscribe by passing the name of the subscriber object. Note
145+
# that this will unsubscribe all subscriptions with the given name:
146+
#
147+
# ActiveSupport::Notifications.unsubscribe("render")
148+
#
144149
# == Default Queue
145150
#
146151
# Notifications ships with a queue implementation that consumes and publishes events
@@ -173,8 +178,8 @@ def subscribed(callback, *args, &block)
173178
unsubscribe(subscriber)
174179
end
175180

176-
def unsubscribe(args)
177-
notifier.unsubscribe(args)
181+
def unsubscribe(subscriber_or_name)
182+
notifier.unsubscribe(subscriber_or_name)
178183
end
179184

180185
def instrumenter

activesupport/lib/active_support/notifications/fanout.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ def subscribe(pattern = nil, block = Proc.new)
2525
subscriber
2626
end
2727

28-
def unsubscribe(subscriber)
28+
def unsubscribe(subscriber_or_name)
2929
synchronize do
30-
@subscribers.reject! { |s| s.matches?(subscriber) }
30+
@subscribers.reject! { |s| s.matches?(subscriber_or_name) }
3131
@listeners_for.clear
3232
end
3333
end

0 commit comments

Comments
 (0)