Class: EQ::Job
- Inherits:
-
Object
- Object
- EQ::Job
- Defined in:
- lib/eq/job.rb
Defined Under Namespace
Classes: UnknownJobClassError
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
Instance Method Summary collapse
- #config(name) ⇒ Object
-
#initialize(id, queue, payload = nil) ⇒ Job
constructor
A new instance of Job.
- #job_class ⇒ Object
-
#perform ⇒ Object
calls MyJobClass.perform(*payload).
- #unique? ⇒ Boolean
Constructor Details
#initialize(id, queue, payload = nil) ⇒ Job
Returns a new instance of Job.
6 7 8 9 10 |
# File 'lib/eq/job.rb', line 6 def initialize id, queue, payload=nil @id = id @queue = queue.to_s @payload = payload end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/eq/job.rb', line 4 def id @id end |
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
4 5 6 |
# File 'lib/eq/job.rb', line 4 def payload @payload end |
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
4 5 6 |
# File 'lib/eq/job.rb', line 4 def queue @queue end |
Instance Method Details
#config(name) ⇒ Object
27 28 29 |
# File 'lib/eq/job.rb', line 27 def config name job_class.instance_variable_get "@#{name}" end |
#job_class ⇒ Object
17 18 19 20 21 |
# File 'lib/eq/job.rb', line 17 def job_class queue.split("::").inject(Kernel){|constant,part| constant.const_get(part)} rescue NameError => e raise UnknownJobClassError, e.to_s end |
#perform ⇒ Object
calls MyJobClass.perform(*payload)
13 14 15 |
# File 'lib/eq/job.rb', line 13 def perform job_class.perform *payload end |
#unique? ⇒ Boolean
23 24 25 |
# File 'lib/eq/job.rb', line 23 def unique? config(:unique) == true end |