aboutsummaryrefslogtreecommitdiffstats
path: root/lib/action_cable
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2015-06-18 17:01:04 +0200
committerDavid Heinemeier Hansson <david@loudthinking.com>2015-06-18 17:01:04 +0200
commit8bd5a80ec5b6c11b3d477fa3af36cbe6e860bb4b (patch)
tree84557aca8acb79f7c9445d2fe6ec3444b3ae5dcb /lib/action_cable
parentcd165923aecfeecae81ee65329c77572c6a8363e (diff)
downloadrails-8bd5a80ec5b6c11b3d477fa3af36cbe6e860bb4b.tar.gz
rails-8bd5a80ec5b6c11b3d477fa3af36cbe6e860bb4b.tar.bz2
rails-8bd5a80ec5b6c11b3d477fa3af36cbe6e860bb4b.zip
Allow unsubscribing from all current redis channels
Diffstat (limited to 'lib/action_cable')
-rw-r--r--lib/action_cable/channel/redis.rb21
1 files changed, 9 insertions, 12 deletions
diff --git a/lib/action_cable/channel/redis.rb b/lib/action_cable/channel/redis.rb
index 6fc6ac179f..6d114eee7e 100644
--- a/lib/action_cable/channel/redis.rb
+++ b/lib/action_cable/channel/redis.rb
@@ -1,11 +1,10 @@
module ActionCable
module Channel
-
module Redis
extend ActiveSupport::Concern
included do
- on_unsubscribe :unsubscribe_from_redis_channels
+ on_unsubscribe :unsubscribe_from_all_channels
delegate :pubsub, to: :connection
end
@@ -18,24 +17,22 @@ module ActionCable
pubsub.subscribe(redis_channel, &callback)
end
- protected
- def unsubscribe_from_redis_channels
- if @_redis_channels
- @_redis_channels.each do |channel, callback|
- logger.info "Unsubscribing from the redis channel: #{channel}"
- pubsub.unsubscribe_proc(channel, callback)
- end
+ def unsubscribe_from_all_channels
+ if @_redis_channels
+ @_redis_channels.each do |channel, callback|
+ logger.info "Unsubscribing from the redis channel: #{channel}"
+ pubsub.unsubscribe_proc(channel, callback)
end
end
+ end
+ protected
def default_subscription_callback(channel)
-> (message) do
logger.info "Received a message over the redis channel: #{channel}"
broadcast ActiveSupport::JSON.decode(message)
end
end
-
end
-
end
-end \ No newline at end of file
+end