No commit activity in last 3 years
No release in over 3 years
Resque-Methodize is a plugin for the Resque job library that allows easy triggering of individual methods on a job class.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 0.0.0
 Project Readme

Resque Methodize

Extends Resque to allow you to call individual methods on a job class. This allows you to group common jobs in a single class rather than having multiple classes that differ slightly or more complex logic to handle variations within a single job.

For example:

require 'resque/plugins/methodize'

class MyJob
  extend Resque::Plugins::Methodize
  @queue = :jobs
  
  def sample1
    puts "Doing stuff"
  end
  
  def sample2(message)
    puts "Doing other stuff while #{message}"
  end
end

# Enqueue the job
MyJob.enqueue_sample1
MyJob.enqueue_sample2('taking out the garbage')

This allows a shorter notation for triggering jobs though "enqueue_method" and calling of a specific instance method within the job.

Inspiration

This plugin was inspired by the task framework cooked up at Involver by Mike Wadhera. The task framework, known as Queueable, is built on top of JMS and runs on JRuby. It follows the same process of tasks being instance methods and similar notation for enqueuing. I personally use Resque and wanted to bring that kind of notation and style to my usage of Resque.