Created
May 7, 2010 21:22
-
-
Save redsquirrel/394015 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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