Class: Redis::Subscription

Inherits:
Object
  • Object
show all
Defined in:
lib/redis/subscribe.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Subscription

Returns a new instance of Subscription.

Yields:

  • (_self)

Yield Parameters:



50
51
52
53
54
55
56
# File 'lib/redis/subscribe.rb', line 50

def initialize
  @callbacks = Hash.new do |hash, key|
    hash[key] = lambda { |*_| }
  end

  yield(self)
end

Instance Attribute Details

#callbacksObject (readonly)

Returns the value of attribute callbacks.



48
49
50
# File 'lib/redis/subscribe.rb', line 48

def callbacks
  @callbacks
end

Instance Method Details

#message(&block) ⇒ Object



66
67
68
# File 'lib/redis/subscribe.rb', line 66

def message(&block)
  @callbacks["message"] = block
end

#pmessage(&block) ⇒ Object



78
79
80
# File 'lib/redis/subscribe.rb', line 78

def pmessage(&block)
  @callbacks["pmessage"] = block
end

#psubscribe(&block) ⇒ Object



70
71
72
# File 'lib/redis/subscribe.rb', line 70

def psubscribe(&block)
  @callbacks["psubscribe"] = block
end

#punsubscribe(&block) ⇒ Object



74
75
76
# File 'lib/redis/subscribe.rb', line 74

def punsubscribe(&block)
  @callbacks["punsubscribe"] = block
end

#subscribe(&block) ⇒ Object



58
59
60
# File 'lib/redis/subscribe.rb', line 58

def subscribe(&block)
  @callbacks["subscribe"] = block
end

#unsubscribe(&block) ⇒ Object



62
63
64
# File 'lib/redis/subscribe.rb', line 62

def unsubscribe(&block)
  @callbacks["unsubscribe"] = block
end