Class: DJ::Worker

Inherits:
Object
  • Object
show all
Includes:
Delayed::Job::Extras
Defined in:
lib/delayed_job_extras/worker.rb,
lib/delayed_job_test_enhancements.rb

Direct Known Subclasses

Mail::Message::MailmanWorker

Constant Summary

Constants included from Delayed::Job::Extras

Delayed::Job::Extras::PRIORITY_LEVELS

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Delayed::Job::Extras

included

Constructor Details

#initialize(attributes = {}) ⇒ Worker

Returns a new instance of Worker.



7
8
9
10
11
# File 'lib/delayed_job_extras/worker.rb', line 7

def initialize(attributes = {})
  self.attributes = attributes
  self.attributes = self.attributes.stringify_keys
  self.id = self.attributes['id']
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args, &block) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/delayed_job_extras/worker.rb', line 13

def method_missing(sym, *args, &block)
  attribute = sym.to_s
  case attribute
  when /(.+)\=$/
    self.attributes[$1] = args.first
  when /(.+)\?$/
    # self.attributes.has_key?($1.to_sym)
    return self.attributes[$1]
  else
    return self.attributes[attribute]
  end
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



5
6
7
# File 'lib/delayed_job_extras/worker.rb', line 5

def attributes
  @attributes
end

Class Method Details

.disable_re_enqueueObject



23
24
25
26
27
28
29
30
31
32
# File 'lib/delayed_job_test_enhancements.rb', line 23

def disable_re_enqueue
  # puts "disabling enqueue_again"
  eval %{
    class Delayed::Job
      def enqueue_again
        # puts "re enqueing has been disabled!"
      end
    end
  }
end