class Redis::SubscribedClient
def call(*args)
Starting with 2.2.1, assume that this method is called with a single
def call(*args) if args.first.is_a?(Array) && args.size == 1 command = args.first else command = args end @client.process([command]) end
def call_without_reply(command)
Assume that this method is called with a single array argument. No
def call_without_reply(command) @commands.push command nil end
def initialize(client)
def initialize(client) @client = client end
def psubscribe(*channels, &block)
def psubscribe(*channels, &block) subscription("psubscribe", "punsubscribe", channels, block) end
def punsubscribe(*channels)
def punsubscribe(*channels) call [:punsubscribe, *channels] end
def subscribe(*channels, &block)
def subscribe(*channels, &block) subscription("subscribe", "unsubscribe", channels, block) end
def subscription(start, stop, channels, block)
def subscription(start, stop, channels, block) sub = Subscription.new(&block) begin @client.call_loop([start, *channels]) do |line| type, *rest = line sub.callbacks[type].call(*rest) break if type == stop && rest.last == 0 end ensure send(stop) end end
def unsubscribe(*channels)
def unsubscribe(*channels) call [:unsubscribe, *channels] end