Sha256: a77eaed9e60b00ee4276d5b1b823cc9ee3efcc51896480c4659f8a154888f3bd
Contents?: true
Size: 1.07 KB
Versions: 13
Compression:
Stored size: 1.07 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 attr_reader :subscribers 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
13 entries across 13 versions & 1 rubygems