Class: Tavern::Redis::Hub
- Inherits:
-
Hub
- Object
- Hub
- Tavern::Redis::Hub
- Defined in:
- lib/tavern/redis/hub.rb
Instance Attribute Summary collapse
-
#redis ⇒ Object
readonly
Returns the value of attribute redis.
Instance Method Summary collapse
-
#initialize(redis = Redis.current) ⇒ Hub
constructor
A new instance of Hub.
- #local_publish ⇒ Object
-
#publish(name, context = {}) ⇒ Object
Now, provide our own local publish.
- #start ⇒ Object
Constructor Details
Instance Attribute Details
#redis ⇒ Object (readonly)
Returns the value of attribute redis.
7 8 9 |
# File 'lib/tavern/redis/hub.rb', line 7 def redis @redis end |
Instance Method Details
#local_publish ⇒ Object
14 |
# File 'lib/tavern/redis/hub.rb', line 14 alias local_publish publish |
#publish(name, context = {}) ⇒ Object
Now, provide our own local publish.
17 18 19 |
# File 'lib/tavern/redis/hub.rb', line 17 def publish(name, context = {}) redis.publish "event:#{name}", MultiJson.dump(context) end |
#start ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/tavern/redis/hub.rb', line 21 def start redis.psubscribe "event:*" do |on| on. do |_, channel, | receive_json channel, end end end |