Module: TResque::Worker

Extended by:
ActiveSupport::Concern
Included in:
DelayExecutionWorker
Defined in:
lib/tresque/worker.rb

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#enqueued_optionsObject (readonly)

Returns the value of attribute enqueued_options.



200
201
202
# File 'lib/tresque/worker.rb', line 200

def enqueued_options
  @enqueued_options
end

Instance Method Details

#initialize(options = {}) ⇒ Object



201
202
203
# File 'lib/tresque/worker.rb', line 201

def initialize(options = {})
  @enqueued_options = options.with_indifferent_access
end

#requeueObject



214
215
216
217
218
219
220
221
# File 'lib/tresque/worker.rb', line 214

def requeue
  self.enqueued_options["run_at"] = nil
  delay = self.requeue_delay_seconds
  if delay > 0
    self.enqueued_options["run_at"] = delay.seconds.from_now
  end
  self.class.enqueue(self.enqueued_options)
end

#requeue!Object

Raises:

  • (Resque::Job::DontPerform)


223
224
225
226
# File 'lib/tresque/worker.rb', line 223

def requeue!
  requeue
  raise Resque::Job::DontPerform
end

#requeue_delay_secondsObject



210
211
212
# File 'lib/tresque/worker.rb', line 210

def requeue_delay_seconds
  1
end

#worker_performObject



205
206
207
208
# File 'lib/tresque/worker.rb', line 205

def worker_perform
  to_call = self.enqueued_options[:action] || :work
  send(to_call)
end