Class: Chef::EventDispatch::Dispatcher

Inherits:
Base show all
Defined in:
lib/chef/event_dispatch/dispatcher.rb

Overview

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.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#attribute_file_load_failed, #attribute_file_loaded, #attribute_load_complete, #attribute_load_start, #converge_complete, #converge_start, #cookbook_clean_complete, #cookbook_clean_start, #cookbook_resolution_complete, #cookbook_resolution_failed, #cookbook_resolution_start, #cookbook_sync_complete, #cookbook_sync_failed, #cookbook_sync_start, #definition_file_load_failed, #definition_file_loaded, #definition_load_complete, #definition_load_start, #handler_executed, #handlers_completed, #handlers_start, #library_file_load_failed, #library_file_loaded, #library_load_complete, #library_load_start, #lwrp_file_load_failed, #lwrp_file_loaded, #lwrp_load_complete, #lwrp_load_start, #msg, #node_load_completed, #node_load_failed, #node_load_start, #ohai_completed, #provider_requirement_failed, #recipe_file_load_failed, #recipe_file_loaded, #recipe_load_complete, #recipe_load_start, #recipe_not_found, #registration_completed, #registration_failed, #registration_start, #removed_cookbook_file, #resource_action_start, #resource_bypassed, #resource_completed, #resource_current_state_load_bypassed, #resource_current_state_loaded, #resource_failed, #resource_failed_retriable, #resource_skipped, #resource_up_to_date, #resource_update_applied, #resource_updated, #run_completed, #run_failed, #run_list_expand_failed, #run_start, #skipping_registration, #synchronized_cookbook, #updated_cookbook_file, #whyrun_assumption

Constructor Details

#initialize(*subscribers) ⇒ Dispatcher

Returns a new instance of Dispatcher.


12
13
14
# File 'lib/chef/event_dispatch/dispatcher.rb', line 12

def initialize(*subscribers)
  @subscribers = subscribers
end

Class Method Details

.def_forwarding_method(method_name) ⇒ Object

Define a method that will be forwarded to all


27
28
29
30
31
32
33
# File 'lib/chef/event_dispatch/dispatcher.rb', line 27

def self.def_forwarding_method(method_name)
  class_eval(<<-END_OF_METHOD, __FILE__, __LINE__)
    def #{method_name}(*args)
      @subscribers.each {|s| s.#{method_name}(*args)}
    end
  END_OF_METHOD
end

Instance Method Details

#register(subscriber) ⇒ Object

Add a new subscriber to the list of registered subscribers


17
18
19
# File 'lib/chef/event_dispatch/dispatcher.rb', line 17

def register(subscriber)
  @subscribers << subscriber
end