Module: Meerkat

Extended by:
Meerkat
Included in:
Meerkat
Defined in:
lib/meerkat.rb,
lib/meerkat/version.rb,
lib/meerkat/backend/pg.rb,
lib/meerkat/rackadapter.rb,
lib/meerkat/backend/amqp.rb,
lib/meerkat/backend/redis.rb,
lib/meerkat/backend/inmemory.rb

Defined Under Namespace

Modules: Backend Classes: RackAdapter

Constant Summary collapse

VERSION =
"0.6.0"

Instance Method Summary collapse

Instance Method Details

#backend=(backend) ⇒ Object



8
9
10
# File 'lib/meerkat.rb', line 8

def backend=(backend)
  @backend = backend
end

#publish(topic, message, is_json = false) ⇒ Object



12
13
14
15
16
17
# File 'lib/meerkat.rb', line 12

def publish(topic, message, is_json = false)
  raise "Topic is required" if topic.nil?
  raise "Message is required" if message.nil?
  json = is_json ? message : MultiJson.encode(message)
  @backend.publish(topic, json) 
end

#subscribe(topic, &callback) ⇒ Object



19
20
21
22
# File 'lib/meerkat.rb', line 19

def subscribe(topic, &callback)
  raise "Topic is required" if topic.nil?
  @backend.subscribe(topic, &callback)
end

#unsubscribe(sid) ⇒ Object



24
25
26
# File 'lib/meerkat.rb', line 24

def unsubscribe(sid)
  @backend.unsubscribe(sid)
end