Module: JobStatus::TrackedJob
- Defined in:
- lib/job_status/tracked_job.rb
Overview
Methods to be included within a worker when this module is used with the include keyword
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.included(base) ⇒ Object
Setup the callbacks within the worker class.
Instance Method Summary collapse
-
#at(job_id, at) ⇒ Object
Store the current position.
-
#store(job_id, store) ⇒ Object
Store data for the provided job_id.
-
#total(job_id, total) ⇒ Object
Store the the total for the job.
Class Method Details
.included(base) ⇒ Object
Setup the callbacks within the worker class
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/job_status/tracked_job.rb', line 12 def self.included(base) base.extend ClassMethods base.class_eval do before_enqueue { JobStatus::Tracker.enqueue(@job_id) } before_perform { JobStatus::Tracker.update(@job_id, :working ) } after_perform { JobStatus::Tracker.update(@job_id, :completed ) } end end |
Instance Method Details
#at(job_id, at) ⇒ Object
Store the current position
29 30 31 |
# File 'lib/job_status/tracked_job.rb', line 29 def at(job_id, at) storage(job_id, :at, at) end |
#store(job_id, store) ⇒ Object
Store data for the provided job_id
49 50 51 |
# File 'lib/job_status/tracked_job.rb', line 49 def store(job_id, store) storage(job_id, :store, store) end |
#total(job_id, total) ⇒ Object
Store the the total for the job
39 40 41 |
# File 'lib/job_status/tracked_job.rb', line 39 def total(job_id, total) storage(job_id, :total, total) end |