Skip to content

Instantly share code, notes, and snippets.

@redsquirrel
Created May 7, 2010 21:22
Show Gist options
  • Save redsquirrel/394015 to your computer and use it in GitHub Desktop.
Save redsquirrel/394015 to your computer and use it in GitHub Desktop.
module ResqueHelper
def already_queued?(queue = @queue, &block)
queue_data = Resque.peek(queue, 0, -1)
return false unless queue_data
case queue_data
when Array
queue_data.any? do |job|
block.call(job["args"])
end
when Hash
args = queue_data["args"]
return block.call(args)
else
return false
end
end
module_function :already_queued?
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment