Module: Backrub

Extended by:
Backrub
Included in:
Backrub
Defined in:
lib/backrub.rb,
lib/backrub/version.rb,
lib/backrub/store/base.rb,
lib/backrub/store/redis.rb

Defined Under Namespace

Modules: Store

Constant Summary collapse

VERSION =
"2.0.0"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#storeObject



9
10
11
# File 'lib/backrub.rb', line 9

def store
  @store ||= Backrub::Store::Redis.new
end

Instance Method Details

#publish(channel, message) ⇒ Object



23
24
25
# File 'lib/backrub.rb', line 23

def publish(channel, message)
  store.publish(channel, message)
end

#subscribe(channels_with_backlog, &block) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/backrub.rb', line 13

def subscribe(channels_with_backlog, &block)
  channels_with_backlog.each do |channel, count|
    store.backlog(channel.to_s, count.to_i, &block) unless count.zero?
  end

  channels = channels_with_backlog.keys.map(&:to_s)

  store.subscribe(*channels, &block)
end