Sha256: fccd43a659208c63100c5dbac84545ee562052f12820ba324b34273d8cfe7ce9

Contents?: true

Size: 1.04 KB

Versions: 18

Compression:

Stored size: 1.04 KB

Contents

require 'chef/event_dispatch/base'

class Chef
  module EventDispatch

    # == 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 Dispatcher < Base

      def initialize(*subscribers)
        @subscribers = subscribers
      end

      # Add a new subscriber to the list of registered subscribers
      def register(subscriber)
        @subscribers << subscriber
      end

      ####
      # All messages are unconditionally forwarded to all subscribers, so just
      # define the forwarding in one go:
      #

      # Define a method that will be forwarded to all
      def self.def_forwarding_method(method_name)
        define_method(method_name) do |*args|
          @subscribers.each { |s| s.send(method_name, *args) }
        end
      end

      (Base.instance_methods - Object.instance_methods).each do |method_name|
        def_forwarding_method(method_name)
      end

    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
chef-12.3.0-x86-mingw32 lib/chef/event_dispatch/dispatcher.rb
chef-12.3.0 lib/chef/event_dispatch/dispatcher.rb
chef-12.3.0.rc.0-x86-mingw32 lib/chef/event_dispatch/dispatcher.rb
chef-12.3.0.rc.0 lib/chef/event_dispatch/dispatcher.rb
chef-12.2.1-x86-mingw32 lib/chef/event_dispatch/dispatcher.rb
chef-12.2.1 lib/chef/event_dispatch/dispatcher.rb
chef-12.2.0.rc.2-x86-mingw32 lib/chef/event_dispatch/dispatcher.rb
chef-12.2.0.rc.2 lib/chef/event_dispatch/dispatcher.rb
chef-12.2.0.rc.1-x86-mingw32 lib/chef/event_dispatch/dispatcher.rb
chef-12.2.0.rc.1 lib/chef/event_dispatch/dispatcher.rb
chef-12.1.2 lib/chef/event_dispatch/dispatcher.rb
chef-12.1.2-x86-mingw32 lib/chef/event_dispatch/dispatcher.rb
chef-12.1.1-x86-mingw32 lib/chef/event_dispatch/dispatcher.rb
chef-12.1.1 lib/chef/event_dispatch/dispatcher.rb
chef-12.1.0-x86-mingw32 lib/chef/event_dispatch/dispatcher.rb
chef-12.1.0 lib/chef/event_dispatch/dispatcher.rb
chef-12.1.0.rc.0-x86-mingw32 lib/chef/event_dispatch/dispatcher.rb
chef-12.1.0.rc.0 lib/chef/event_dispatch/dispatcher.rb