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.
60 61 62 63 64 65 66 |
# File 'lib/redis/subscribe.rb', line 60 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.
58 59 60 |
# File 'lib/redis/subscribe.rb', line 58 def callbacks @callbacks end |
Instance Method Details
#message(&block) ⇒ Object
76 77 78 |
# File 'lib/redis/subscribe.rb', line 76 def (&block) @callbacks["message"] = block end |
#pmessage(&block) ⇒ Object
88 89 90 |
# File 'lib/redis/subscribe.rb', line 88 def (&block) @callbacks["pmessage"] = block end |
#psubscribe(&block) ⇒ Object
80 81 82 |
# File 'lib/redis/subscribe.rb', line 80 def psubscribe(&block) @callbacks["psubscribe"] = block end |
#punsubscribe(&block) ⇒ Object
84 85 86 |
# File 'lib/redis/subscribe.rb', line 84 def punsubscribe(&block) @callbacks["punsubscribe"] = block end |
#subscribe(&block) ⇒ Object
68 69 70 |
# File 'lib/redis/subscribe.rb', line 68 def subscribe(&block) @callbacks["subscribe"] = block end |
#unsubscribe(&block) ⇒ Object
72 73 74 |
# File 'lib/redis/subscribe.rb', line 72 def unsubscribe(&block) @callbacks["unsubscribe"] = block end |