Method: Resque::Plugins::State::ClassMethods#enqueue_to

Defined in:
lib/resque/plugins/state.rb

#enqueue_to(queue, klass, options = {}) ⇒ Object

Adds a job of type <tt>klass<tt> to a specified queue with <tt>options<tt>.

Returns the UUID of the job if the job was queued, or nil if the job was rejected by a before_enqueue hook.



120
121
122
123
124
125
126
127
128
129
130
# File 'lib/resque/plugins/state.rb', line 120

def enqueue_to(queue, klass, options = {})
  uuid = Resque::Plugins::State::Hash.generate_uuid
  Resque::Plugins::State::Hash.create uuid, options: options

  if Resque.enqueue_to(queue, klass, uuid, options)
    uuid
  else
    Resque::Plugins::State::Hash.remove(uuid)
    nil
  end
end