Class: Redis::Subscription
- Inherits:
-
Object
- Object
- Redis::Subscription
- Defined in:
- lib/redis/subscribe.rb
Instance Attribute Summary collapse
-
#callbacks ⇒ Object
readonly
Returns the value of attribute callbacks.
Instance Method Summary collapse
-
#initialize {|_self| ... } ⇒ Subscription
constructor
A new instance of Subscription.
- #message(&block) ⇒ Object
- #pmessage(&block) ⇒ Object
- #psubscribe(&block) ⇒ Object
- #punsubscribe(&block) ⇒ Object
- #subscribe(&block) ⇒ Object
- #unsubscribe(&block) ⇒ Object
Constructor Details
#initialize {|_self| ... } ⇒ Subscription
Returns a new instance of Subscription.
47 48 49 50 51 52 53 |
# File 'lib/redis/subscribe.rb', line 47 def initialize @callbacks = Hash.new do |hash, key| hash[key] = lambda { |*_| } end yield(self) end |
Instance Attribute Details
#callbacks ⇒ Object (readonly)
Returns the value of attribute callbacks.
45 46 47 |
# File 'lib/redis/subscribe.rb', line 45 def callbacks @callbacks end |
Instance Method Details
#message(&block) ⇒ Object
63 64 65 |
# File 'lib/redis/subscribe.rb', line 63 def (&block) @callbacks["message"] = block end |
#pmessage(&block) ⇒ Object
75 76 77 |
# File 'lib/redis/subscribe.rb', line 75 def (&block) @callbacks["pmessage"] = block end |
#psubscribe(&block) ⇒ Object
67 68 69 |
# File 'lib/redis/subscribe.rb', line 67 def psubscribe(&block) @callbacks["psubscribe"] = block end |
#punsubscribe(&block) ⇒ Object
71 72 73 |
# File 'lib/redis/subscribe.rb', line 71 def punsubscribe(&block) @callbacks["punsubscribe"] = block end |
#subscribe(&block) ⇒ Object
55 56 57 |
# File 'lib/redis/subscribe.rb', line 55 def subscribe(&block) @callbacks["subscribe"] = block end |
#unsubscribe(&block) ⇒ Object
59 60 61 |
# File 'lib/redis/subscribe.rb', line 59 def unsubscribe(&block) @callbacks["unsubscribe"] = block end |