From c88360ef3651702ca8f7f600e15774f51c84698b Mon Sep 17 00:00:00 2001 From: Carlhuda Date: Mon, 1 Mar 2010 16:01:08 -0800 Subject: You can unsubscribe a subscriber --- activesupport/lib/active_support/notifications/fanout.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'activesupport/lib/active_support/notifications/fanout.rb') diff --git a/activesupport/lib/active_support/notifications/fanout.rb b/activesupport/lib/active_support/notifications/fanout.rb index 090eb1eac6..e08011e23f 100644 --- a/activesupport/lib/active_support/notifications/fanout.rb +++ b/activesupport/lib/active_support/notifications/fanout.rb @@ -4,7 +4,7 @@ module ActiveSupport # just pushes events to all registered log subscribers. class Fanout def initialize - @log_subscribers = [] + @subscribers = [] end def bind(pattern) @@ -12,11 +12,16 @@ module ActiveSupport end def subscribe(pattern = nil, &block) - @log_subscribers << Subscriber.new(pattern, &block) + @subscribers << Subscriber.new(pattern, &block) + @subscribers.last + end + + def unsubscribe(subscriber) + @subscribers.delete(subscriber) end def publish(*args) - @log_subscribers.each { |s| s.publish(*args) } + @subscribers.each { |s| s.publish(*args) } end # This is a sync queue, so there is not waiting. -- cgit v1.2.3