From 85ac703585a3bc413571e23d2e7dc3ca1e4cad2e Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Sat, 7 Feb 2015 09:22:22 +0530 Subject: Raise an exception when Server.pubsub class method is not defined --- lib/action_cable/channel/redis.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/action_cable/channel/redis.rb b/lib/action_cable/channel/redis.rb index 00a8230a74..bdbd3c95b1 100644 --- a/lib/action_cable/channel/redis.rb +++ b/lib/action_cable/channel/redis.rb @@ -9,9 +9,10 @@ module ActionCable end def subscribe_to(redis_channel, callback = nil) - @_redis_channels ||= [] + raise "`ActionCable::Server.pubsub` class method is not defined" unless connection.class.respond_to?(:pubsub) callback ||= -> (message) { broadcast ActiveSupport::JSON.decode(message) } + @_redis_channels ||= [] @_redis_channels << [ redis_channel, callback ] pubsub.subscribe(redis_channel, &callback) @@ -25,7 +26,7 @@ module ActionCable end def pubsub - @connection.class.pubsub + connection.class.pubsub end end -- cgit v1.2.3