Module: Callback::InstanceMethods
Instance Method Summary collapse
-
#define_callback(key, callback_proc = nil, &callback_block) ⇒ Object
(also: #register_callback)
Defines the callback for the key on the object.
-
#undefine_callback(key, callback_proc) ⇒ Object
(also: #unregister_callback)
Undefine the callback.
Instance Method Details
#define_callback(key, callback_proc = nil, &callback_block) ⇒ Object Also known as: register_callback
Defines the callback for the key 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.
5 6 7 |
# File 'lib/callback/callback.rb', line 5 def define_callback(key, callback_proc=nil, &callback_block) callbacks.define(key, callback_proc, &callback_block) end |
#undefine_callback(key, callback_proc) ⇒ Object Also known as: unregister_callback
Undefine the callback. The callback proc must be the same object as what was passed to define_callback.
11 12 13 |
# File 'lib/callback/callback.rb', line 11 def undefine_callback(key, callback_proc) callbacks.undefine(key, callback_proc) end |