class ActiveSupport::Notifications::Fanout

This is a default queue implementation that ships with Notifications. It just pushes events to all registered log subscribers.

Public Class Methods

new() click to toggle source
# File lib/active_support/notifications/fanout.rb, line 6
def initialize
  @subscribers = []
  @listeners_for = {}
end

Public Instance Methods

listeners_for(name) click to toggle source
# File lib/active_support/notifications/fanout.rb, line 28
def listeners_for(name)
  @listeners_for[name] ||= @subscribers.select { |s| s.subscribed_to?(name) }
end
listening?(name) click to toggle source
# File lib/active_support/notifications/fanout.rb, line 32
def listening?(name)
  listeners_for(name).any?
end
publish(name, *args) click to toggle source
# File lib/active_support/notifications/fanout.rb, line 24
def publish(name, *args)
  listeners_for(name).each { |s| s.publish(name, *args) }
end
subscribe(pattern = nil, block = Proc.new) click to toggle source
# File lib/active_support/notifications/fanout.rb, line 11
def subscribe(pattern = nil, block = Proc.new)
  subscriber = Subscriber.new(pattern, block).tap do |s|
    @subscribers << s
  end
  @listeners_for.clear
  subscriber
end
unsubscribe(subscriber) click to toggle source
# File lib/active_support/notifications/fanout.rb, line 19
def unsubscribe(subscriber)
  @subscribers.reject! {|s| s.matches?(subscriber)}
  @listeners_for.clear
end
wait() click to toggle source

This is a sync queue, so there is no waiting.

# File lib/active_support/notifications/fanout.rb, line 37
def wait
end