Module: Hookable
- Included in:
- ObjectiveCommand::Runners::Runner
- Defined in:
- lib/hookable.rb
Overview
- Copyright
-
Copyright © 2005 Nicolas Pouillard. All rights reserved.
- Author
-
Nicolas Pouillard <[email protected]>.
- License
-
Gnu General Public License.
- Revision
-
$Id: /w/fey/cmd/trunk/lib/hookable.rb 24388 2006-07-09T17:09:53.202920Z ertai $
Defined Under Namespace
Modules: ClassMethods, Internal Classes: ProcHooker
Instance Method Summary collapse
- #disable_hook(*hook_names) ⇒ Object
- #hook_trigger(name, *args, &block) ⇒ Object
- #hooker_subscribe(hooker) ⇒ Object
- #subscribe_hook(*hook_names, &block) ⇒ Object
Instance Method Details
#disable_hook(*hook_names) ⇒ Object
58 59 60 61 62 |
# File 'lib/hookable.rb', line 58 def disable_hook *hook_names @disabled_hooks ||= [] @disabled_hooks += hook_names self end |
#hook_trigger(name, *args, &block) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/hookable.rb', line 34 def hook_trigger name, *args, &block return if defined? @disabled_hooks and @disabled_hooks.include? name return if disabled_hooks.include? name self.class.hook_trigger(name, *args, &block) return unless defined? @hookers @hookers.each do |hooker| Internal.hook_trigger(hooker, name, *args, &block) end self end |
#hooker_subscribe(hooker) ⇒ Object
46 47 48 49 50 |
# File 'lib/hookable.rb', line 46 def hooker_subscribe hooker @hookers ||= [] @hookers << hooker self end |
#subscribe_hook(*hook_names, &block) ⇒ Object
53 54 55 |
# File 'lib/hookable.rb', line 53 def subscribe_hook *hook_names, &block hooker_subscribe ProcHooker.new(*hook_names, &block) end |