diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2015-02-07 00:49:56 +0530 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2015-02-07 00:49:56 +0530 |
commit | ceedb5fb70f8fc6db85baca2394f769cc7b5251a (patch) | |
tree | 11f972c3bdf8389d7445d23be80c40ca4adcdcfb | |
parent | 55a088167e1f2e10dadefadb5e2e68e2301dba14 (diff) | |
parent | 05309cdf3858d4e65bda3fb31cbf86eed3b21c42 (diff) | |
download | rails-ceedb5fb70f8fc6db85baca2394f769cc7b5251a.tar.gz rails-ceedb5fb70f8fc6db85baca2394f769cc7b5251a.tar.bz2 rails-ceedb5fb70f8fc6db85baca2394f769cc7b5251a.zip |
Merge branch 'master' into celluloid
-rw-r--r-- | lib/action_cable/channel/redis.rb | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/action_cable/channel/redis.rb b/lib/action_cable/channel/redis.rb index 215cc3c975..00a8230a74 100644 --- a/lib/action_cable/channel/redis.rb +++ b/lib/action_cable/channel/redis.rb @@ -10,21 +10,22 @@ module ActionCable def subscribe_to(redis_channel, callback = nil) @_redis_channels ||= [] - @_redis_channels << redis_channel callback ||= -> (message) { broadcast ActiveSupport::JSON.decode(message) } - redis.pubsub.subscribe(redis_channel, &callback) + @_redis_channels << [ redis_channel, callback ] + + pubsub.subscribe(redis_channel, &callback) end protected def unsubscribe_from_redis_channels if @_redis_channels - @_redis_channels.each { |channel| @connection.pubsub.unsubscribe(channel) } + @_redis_channels.each { |channel, callback| pubsub.unsubscribe_proc(channel, callback) } end end - def redis - @connection.redis + def pubsub + @connection.class.pubsub end end |