Method: Resque::Worker#run_hook

Defined in:
lib/resque/worker.rb

#run_hook(name, *args) ⇒ Object

Runs a named hook, passing along any arguments.



690
691
692
693
694
695
696
697
698
699
700
701
702
# File 'lib/resque/worker.rb', line 690

def run_hook(name, *args)
  hooks = Resque.send(name)
  return if hooks.empty?
  return if name == :before_first_fork && @before_first_fork_hook_ran
  msg = "Running #{name} hooks"
  msg << " with #{args.inspect}" if args.any?
  log_with_severity :info, msg

  hooks.each do |hook|
    args.any? ? hook.call(*args) : hook.call
    @before_first_fork_hook_ran = true if name == :before_first_fork
  end
end