bkeepers/qu — comment on commit f70f6bf1a149252c95cdbbaa438a4e2864cf14bd
File:  line 0
By bkeepers:

@stellard Sounds great. I don't personally have a need for it, but I know other people often ask for that. Why don't you start by implementing it as a stand-alone gem, and if it makes sense to pull it into core, then talk about it then.

If you're working off the hooks branch, the easiest thing to do would be to implement it using ActiveSupport::Concern. I wrote more about that here: http://opensoul.org/blog/archives/2011/02/07/concerning-activesupportconcern/

It might look something like this:

```ruby
module Uniqify
extend ActiveSupport::Concern

included do
before_enqueue :ensure_unique
end

def ensure_unique
halt unless job_is_uniq?
end

def job_is_unique?
true # use payload.klass and payload.args to check if job exists in queue
end
end

class MyJob < Qu::Job
include Uniqify

# …
end
```

The challenge with this plugin is that the implementation will vary depending on the backend. I haven't really thought about how to handle this well with plugins. I'd love your feedback.