Module: Callback::InstanceMethods
- Included in:
- Object
- Defined in:
- lib/spec/callback/extensions/object.rb
Instance Method Summary collapse
-
#register_callback(event, callback_proc = nil, &callback_block) ⇒ Object
Registers a callback for the event on the object.
-
#unregister_callback(event, callback_proc) ⇒ Object
Removes the callback from the event.
Instance Method Details
#register_callback(event, callback_proc = nil, &callback_block) ⇒ Object
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.
5 6 7 |
# File 'lib/spec/callback/extensions/object.rb', line 5 def register_callback(event, callback_proc=nil, &callback_block) callbacks.define(event, callback_proc, &callback_block) end |
#unregister_callback(event, callback_proc) ⇒ Object
Removes the callback from the event. The callback proc must be the same object as the one that was passed to register_callback.
11 12 13 |
# File 'lib/spec/callback/extensions/object.rb', line 11 def unregister_callback(event, callback_proc) callbacks.undefine(event, callback_proc) end |