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
-
Class Public methods
Source:
show
| on GitHub
def initialize
@subscribers = []
@listeners_for = {}
end
Instance Public methods
Source:
show
| on GitHub
def listeners_for(name)
@listeners_for[name] ||= @subscribers.select { |s| s.subscribed_to?(name) }
end
Source:
show
| on GitHub
def listening?(name)
listeners_for(name).any?
end
Source:
show
| on GitHub
def publish(name, *args)
listeners_for(name).each { |s| s.publish(name, *args) }
end
subscribe(pattern = nil, block = Proc.new)
Source:
show
| on GitHub
def subscribe(pattern = nil, block = Proc.new)
subscriber = Subscriber.new(pattern, block).tap do |s|
@subscribers << s
end
@listeners_for.clear
subscriber
end
Source:
show
| on GitHub
def unsubscribe(subscriber)
@subscribers.reject! {|s| s.matches?(subscriber)}
@listeners_for.clear
end
This is a sync queue, so there is no waiting.