Skip to content

Instantly share code, notes, and snippets.

@splattael
Forked from scottwater/mail_queue.rb
Created April 28, 2011 09:35
Show Gist options
  • Save splattael/946091 to your computer and use it in GitHub Desktop.
Save splattael/946091 to your computer and use it in GitHub Desktop.
A really simple general purpose mail queue for resque
module MailQueue
extend self
def queue
:default
end
def perform(mailer_class, method, *args)
mailer = const_get mailer_class
mailer.send(method, *args).deliver
end
def enqueue()
EnqueueProxy.new(self)
end
class EnqueueProxy
def initialize(klass)
@klass = klass
end
def method_missing(m, *args, &block)
if @klass.respond_to? m
args = [@klass.to_s, m] + args
Resque.enqueue(MailQueue, *args)
else
super
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment