class Chef::EventDispatch::Dispatcher

EventDispatch::Dispatcher

The Dispatcher handles receiving event data from the sources (Chef::Client, Resources and Providers, etc.) and publishing the data to the registered subscribers.

Public Class Methods

def_forwarding_method(method_name) click to toggle source

Define a method that will be forwarded to all

# File lib/chef/event_dispatch/dispatcher.rb, line 27
      def self.def_forwarding_method(method_name)
        class_eval("          def #{method_name}(*args)
            @subscribers.each {|s| s.#{method_name}(*args)}
          end
", __FILE__, __LINE__)
      end
new(*subscribers) click to toggle source
# File lib/chef/event_dispatch/dispatcher.rb, line 12
def initialize(*subscribers)
  @subscribers = subscribers
end

Public Instance Methods

register(subscriber) click to toggle source

Add a new subscriber to the list of registered subscribers

# File lib/chef/event_dispatch/dispatcher.rb, line 17
def register(subscriber)
  @subscribers << subscriber
end