Class: Redis::SubscribedClient
- Inherits:
-
Object
- Object
- Redis::SubscribedClient
- Defined in:
- lib/redis/subscribe.rb
Instance Method Summary collapse
-
#call(*args) ⇒ Object
Starting with 2.2.1, assume that this method is called with a single array argument.
-
#call_without_reply(command) ⇒ Object
Assume that this method is called with a single array argument.
-
#initialize(client) ⇒ SubscribedClient
constructor
A new instance of SubscribedClient.
- #psubscribe(*channels, &block) ⇒ Object
- #punsubscribe(*channels) ⇒ Object
- #subscribe(*channels, &block) ⇒ Object
- #unsubscribe(*channels) ⇒ Object
Constructor Details
#initialize(client) ⇒ SubscribedClient
Returns a new instance of SubscribedClient.
3 4 5 |
# File 'lib/redis/subscribe.rb', line 3 def initialize(client) @client = client end |
Instance Method Details
#call(*args) ⇒ Object
Starting with 2.2.1, assume that this method is called with a single array argument. Check its size for backwards compat.
9 10 11 12 13 14 15 16 17 |
# File 'lib/redis/subscribe.rb', line 9 def call(*args) if args.first.is_a?(Array) && args.size == 1 command = args.first else command = args end @client.process([command]) end |
#call_without_reply(command) ⇒ Object
Assume that this method is called with a single array argument. No backwards compat here, since it was introduced in 2.2.2.
21 22 23 24 |
# File 'lib/redis/subscribe.rb', line 21 def call_without_reply(command) @commands.push command nil end |
#psubscribe(*channels, &block) ⇒ Object
30 31 32 |
# File 'lib/redis/subscribe.rb', line 30 def psubscribe(*channels, &block) subscription("psubscribe", "punsubscribe", channels, block) end |
#punsubscribe(*channels) ⇒ Object
38 39 40 |
# File 'lib/redis/subscribe.rb', line 38 def punsubscribe(*channels) call [:punsubscribe, *channels] end |
#subscribe(*channels, &block) ⇒ Object
26 27 28 |
# File 'lib/redis/subscribe.rb', line 26 def subscribe(*channels, &block) subscription("subscribe", "unsubscribe", channels, block) end |
#unsubscribe(*channels) ⇒ Object
34 35 36 |
# File 'lib/redis/subscribe.rb', line 34 def unsubscribe(*channels) call [:unsubscribe, *channels] end |