diff options
Diffstat (limited to 'test/lib/spec/callback/extensions')
| -rw-r--r-- | test/lib/spec/callback/extensions/module.rb | 24 | ||||
| -rw-r--r-- | test/lib/spec/callback/extensions/object.rb | 37 |
2 files changed, 0 insertions, 61 deletions
diff --git a/test/lib/spec/callback/extensions/module.rb b/test/lib/spec/callback/extensions/module.rb deleted file mode 100644 index 429268ed1..000000000 --- a/test/lib/spec/callback/extensions/module.rb +++ /dev/null @@ -1,24 +0,0 @@ -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 diff --git a/test/lib/spec/callback/extensions/object.rb b/test/lib/spec/callback/extensions/object.rb deleted file mode 100644 index c6ac6fd14..000000000 --- a/test/lib/spec/callback/extensions/object.rb +++ /dev/null @@ -1,37 +0,0 @@ -module Callback - module InstanceMethods - # Registers a callback for the event on the object. The callback can either be a block or a proc. - # When the callbacks are notified, the return value of the proc is passed to the caller. - def register_callback(event, callback_proc=nil, &callback_block) - callbacks.define(event, callback_proc, &callback_block) - end - - # Removes the callback from the event. The callback proc must be the same - # object as the one that was passed to register_callback. - def unregister_callback(event, callback_proc) - callbacks.undefine(event, callback_proc) - end - - protected - # Notifies the callbacks registered with the event on the object. Arguments can be passed to the callbacks. - # An error handler may be passed in as a block. If there is an error, the block is called with - # error object as an argument. - # An array of the return values of the callbacks is returned. - def notify_callbacks(event, *args, &error_handler) - callbacks.notify(event, *args, &error_handler) - end - - def notify_class_callbacks(event, *args, &error_handler) - self.class.send(:notify_callbacks, event, *args, &error_handler) - end - - # The CallbackContainer for this object. - def callbacks - @callbacks ||= CallbackContainer.new - end - end -end - -class Object - include Callback::InstanceMethods -end
\ No newline at end of file |
