Method: Guard::Plugin#hook
- Defined in:
- lib/guard/plugin.rb
#hook(event, *args) ⇒ Object
When event is a Symbol, #hook will generate a hook name by concatenating the method name from where #hook is called with the given Symbol.
Here, when #run_all is called, #hook will notify callbacks registered for the “run_all_foo” event.
When event is a String, #hook will directly turn the String into a Symbol.
When run_all is called, #hook will notify callbacks registered for the “foo_bar” event.
116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/guard/plugin.rb', line 116 def hook(event, *args) hook_name = if event.is_a? Symbol calling_method = caller[0][/`([^']*)'/, 1] "#{ calling_method }_#{ event }" else event end UI.debug "Hook :#{ hook_name } executed for #{ self.class }" self.class.notify(self, hook_name.to_sym, *args) end |