module Resque::Plugin

Constants

LintError

Public Instance Methods

after_dequeue_hooks(job) click to toggle source

Given an object, returns a list `after_dequeue` hook names.

# File lib/resque/plugin.rb, line 57
def after_dequeue_hooks(job)
  job.methods.grep(/^after_dequeue/).sort
end
after_enqueue_hooks(job) click to toggle source

Given an object, returns a list `after_enqueue` hook names.

# File lib/resque/plugin.rb, line 47
def after_enqueue_hooks(job)
  job.methods.grep(/^after_enqueue/).sort
end
after_hooks(job) click to toggle source

Given an object, returns a list `after_perform` hook names.

# File lib/resque/plugin.rb, line 37
def after_hooks(job)
  job.methods.grep(/^after_perform/).sort
end
around_hooks(job) click to toggle source

Given an object, returns a list `around_perform` hook names.

# File lib/resque/plugin.rb, line 32
def around_hooks(job)
  job.methods.grep(/^around_perform/).sort
end
before_dequeue_hooks(job) click to toggle source

Given an object, returns a list `before_dequeue` hook names.

# File lib/resque/plugin.rb, line 62
def before_dequeue_hooks(job)
  job.methods.grep(/^before_dequeue/).sort
end
before_enqueue_hooks(job) click to toggle source

Given an object, returns a list `before_enqueue` hook names.

# File lib/resque/plugin.rb, line 52
def before_enqueue_hooks(job)
  job.methods.grep(/^before_enqueue/).sort
end
before_hooks(job) click to toggle source

Given an object, returns a list `before_perform` hook names.

# File lib/resque/plugin.rb, line 27
def before_hooks(job)
  job.methods.grep(/^before_perform/).sort
end
failure_hooks(job) click to toggle source

Given an object, returns a list `on_failure` hook names.

# File lib/resque/plugin.rb, line 42
def failure_hooks(job)
  job.methods.grep(/^on_failure/).sort
end
lint(plugin) click to toggle source

Ensure that your plugin conforms to good hook naming conventions.

Resque::Plugin.lint(MyResquePlugin)
# File lib/resque/plugin.rb, line 10
def lint(plugin)
  hooks = before_hooks(plugin) + around_hooks(plugin) + after_hooks(plugin)

  hooks.each do |hook|
    if hook =~ /perform$/
      raise LintError, "#{plugin}.#{hook} is not namespaced"
    end
  end

  failure_hooks(plugin).each do |hook|
    if hook =~ /failure$/
      raise LintError, "#{plugin}.#{hook} is not namespaced"
    end
  end
end