Class: Redis::Subscription

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

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Subscription) initialize {|_self| ... }

Returns a new instance of Subscription

Yields:

  • (_self)

Yield Parameters:



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

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

  yield(self)
end

Instance Attribute Details

- (Object) callbacks (readonly)

Returns the value of attribute callbacks



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

def callbacks
  @callbacks
end

Instance Method Details

- (Object) message(&block)



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

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

- (Object) pmessage(&block)



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

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

- (Object) psubscribe(&block)



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

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

- (Object) punsubscribe(&block)



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

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

- (Object) subscribe(&block)



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

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

- (Object) unsubscribe(&block)



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

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