Class: GovernorBackground::Resque::Job
- Inherits:
-
Object
- Object
- GovernorBackground::Resque::Job
- Defined in:
- lib/governor_background/resque/job.rb
Overview
A wrapper around a Resque job.
Instance Attribute Summary collapse
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#completed? ⇒ Boolean
Returns true if this job has been completed, false otherwise.
-
#failed? ⇒ Boolean
Returns true if this job has failed, false otherwise.
-
#initialize(name, job_id) ⇒ Job
constructor
Initializes the job with a job name (passed from
GovernorBackground.run
) and a unique identifier for the Resque job. -
#killed? ⇒ Boolean
Returns true if this job has been killed, false otherwise.
-
#message ⇒ Object
Returns a human readable message describing the status.
-
#queued? ⇒ Boolean
Returns true if this job is currently waiting in the queue, false otherwise.
-
#status ⇒ Object
Returns the status of the job, which can be any of the boolean methods or
unknown
. -
#working? ⇒ Boolean
Returns true if this job is currently being processed, false otherwise.
Constructor Details
#initialize(name, job_id) ⇒ Job
Initializes the job with a job name (passed from GovernorBackground.run
) and a unique identifier for the Resque job.
9 10 11 12 13 |
# File 'lib/governor_background/resque/job.rb', line 9 def initialize(name, job_id) @name = name @id = job_id @created_at = Time.now end |
Instance Attribute Details
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
5 6 7 |
# File 'lib/governor_background/resque/job.rb', line 5 def created_at @created_at end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/governor_background/resque/job.rb', line 5 def name @name end |
Instance Method Details
#completed? ⇒ Boolean
Returns true if this job has been completed, false otherwise.
34 35 36 |
# File 'lib/governor_background/resque/job.rb', line 34 def completed? proxy :completed? end |
#failed? ⇒ Boolean
Returns true if this job has failed, false otherwise.
39 40 41 |
# File 'lib/governor_background/resque/job.rb', line 39 def failed? proxy :failed? end |
#killed? ⇒ Boolean
Returns true if this job has been killed, false otherwise.
44 45 46 |
# File 'lib/governor_background/resque/job.rb', line 44 def killed? proxy :killed? end |
#message ⇒ Object
Returns a human readable message describing the status.
49 50 51 |
# File 'lib/governor_background/resque/job.rb', line 49 def proxy :message, '' end |
#queued? ⇒ Boolean
Returns true if this job is currently waiting in the queue, false otherwise.
23 24 25 |
# File 'lib/governor_background/resque/job.rb', line 23 def queued? proxy :queued? end |
#status ⇒ Object
Returns the status of the job, which can be any of the boolean methods or unknown
.
17 18 19 |
# File 'lib/governor_background/resque/job.rb', line 17 def status (job = resque_status) ? job.status : 'unknown' end |
#working? ⇒ Boolean
Returns true if this job is currently being processed, false otherwise.
29 30 31 |
# File 'lib/governor_background/resque/job.rb', line 29 def working? proxy :working? end |