Sha256: 842c40a26dbac8af04652423140da83b397bb86abba992a11be8e8e42e04ef48

Contents?: true

Size: 596 Bytes

Versions: 11

Compression:

Stored size: 596 Bytes

Contents

module Callback
  module ModuleMethods
    # For each event_name submitted, defines a callback event with this name.
    # Client code can then register as a callback listener using object.event_name.
    def callback_events(*event_names)
      event_names.each do |event_name|
        define_callback_event(event_name)
      end
    end

    private
    def define_callback_event(event_name)
      module_eval <<-EOS
        def #{event_name}(&block)
          register_callback(:#{event_name}, &block)
        end
      EOS
    end
  end
end

class Module
  include Callback::ModuleMethods
end

Version data entries

11 entries across 11 versions & 3 rubygems

Version Path
puppet-0.23.0 test/lib/spec/callback/extensions/module.rb
puppet-0.22.4 test/lib/spec/callback/extensions/module.rb
puppet-0.23.2 test/lib/spec/callback/extensions/module.rb
puppet-0.23.1 test/lib/spec/callback/extensions/module.rb
riess-0.0.8 vendor/rspec-0.8.2/lib/spec/callback/extensions/module.rb
rspec-0.7.5 lib/spec/callback/extensions/module.rb
rspec-0.7.5.1 lib/spec/callback/extensions/module.rb
rspec-0.8.0 lib/spec/callback/extensions/module.rb
rspec-0.8.1 lib/spec/callback/extensions/module.rb
rspec-0.7.4 lib/spec/callback/extensions/module.rb
rspec-0.8.2 lib/spec/callback/extensions/module.rb