Class: Redis2::Subscription

Inherits:
Object
  • Object
show all
Defined in:
lib/redis2/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:



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

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.



49
50
51
# File 'lib/redis2/subscribe.rb', line 49

def callbacks
  @callbacks
end

Instance Method Details

#message(&block) ⇒ Object



67
68
69
# File 'lib/redis2/subscribe.rb', line 67

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

#pmessage(&block) ⇒ Object



79
80
81
# File 'lib/redis2/subscribe.rb', line 79

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

#psubscribe(&block) ⇒ Object



71
72
73
# File 'lib/redis2/subscribe.rb', line 71

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

#punsubscribe(&block) ⇒ Object



75
76
77
# File 'lib/redis2/subscribe.rb', line 75

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

#subscribe(&block) ⇒ Object



59
60
61
# File 'lib/redis2/subscribe.rb', line 59

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

#unsubscribe(&block) ⇒ Object



63
64
65
# File 'lib/redis2/subscribe.rb', line 63

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