Module: Guard::Hook::InstanceMethods
- Defined in:
- lib/guard/hook.rb
Overview
Instance methods that gets included in the base class.
Instance Method Summary collapse
Instance Method Details
#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 Guard#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 Guard#run_all is called, #hook will notify callbacks registered for the “foo_bar” event.
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/guard/hook.rb', line 52 def hook(event, *args) hook_name = if event.is_a? Symbol calling_method = caller[0][/`([^']*)'/, 1] "#{ calling_method }_#{ event }" else event end.to_sym UI.debug "Hook :#{ hook_name } executed for #{ self.class }" Hook.notify(self.class, hook_name, *args) end |