This is a default queue implementation that ships with Notifications. It just pushes events to
all registered log subscribers.
Methods
- L
-
- N
-
- P
-
- S
-
- U
-
- W
-
Classes and Modules
Class Public methods
Source: show
| on GitHub
6: def initialize
7: @subscribers = []
8: @listeners_for = {}
9: end
Instance Public methods
Source: show
| on GitHub
28: def listeners_for(name)
29: @listeners_for[name] ||= @subscribers.select { |s| s.subscribed_to?(name) }
30: end
Source: show
| on GitHub
32: def listening?(name)
33: listeners_for(name).any?
34: end
Source: show
| on GitHub
24: def publish(name, *args)
25: listeners_for(name).each { |s| s.publish(name, *args) }
26: end
subscribe(pattern = nil, block = Proc.new)
Source: show
| on GitHub
11: def subscribe(pattern = nil, block = Proc.new)
12: subscriber = Subscriber.new(pattern, block).tap do |s|
13: @subscribers << s
14: end
15: @listeners_for.clear
16: subscriber
17: end
Source: show
| on GitHub
19: def unsubscribe(subscriber)
20: @subscribers.reject! {|s| s.matches?(subscriber)}
21: @listeners_for.clear
22: end
This is a sync queue, so there is no waiting.