module Guard::Hook::InstanceMethods

def hook(event, *args)

Parameters:
  • args (Array) -- the parameters are passed as is to the callbacks registered for the given event.
  • event (Symbol, String) -- the name of the Guard event

Other tags:
    Example: Add a hook with a String -
    Example: Add a hook with a Symbol -
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