Class: Workarea::Scheduler
- Inherits:
-
Object
- Object
- Workarea::Scheduler
- Defined in:
- lib/workarea/scheduler.rb
Instance Attribute Summary collapse
-
#job_id ⇒ Object
readonly
Returns the value of attribute job_id.
Class Method Summary collapse
Instance Method Summary collapse
- #add_job ⇒ Object
- #delete ⇒ Object
-
#initialize(options = {}) ⇒ Scheduler
constructor
A new instance of Scheduler.
- #perform ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Scheduler
Returns a new instance of Scheduler.
15 16 17 18 19 20 |
# File 'lib/workarea/scheduler.rb', line 15 def initialize( = {}) @time = [:at] @worker = [:worker] @args = [:args] @job_id = [:job_id] end |
Instance Attribute Details
#job_id ⇒ Object (readonly)
Returns the value of attribute job_id.
3 4 5 |
# File 'lib/workarea/scheduler.rb', line 3 def job_id @job_id end |
Class Method Details
.delete(job_id) ⇒ Object
11 12 13 |
# File 'lib/workarea/scheduler.rb', line 11 def self.delete(job_id) new(job_id: job_id).delete end |
.schedule(*args) ⇒ Object
5 6 7 8 9 |
# File 'lib/workarea/scheduler.rb', line 5 def self.schedule(*args) instance = new(*args) instance.perform instance.job_id end |
Instance Method Details
#add_job ⇒ Object
31 32 33 |
# File 'lib/workarea/scheduler.rb', line 31 def add_job @job_id = @worker.perform_at(@time, *@args) end |
#delete ⇒ Object
27 28 29 |
# File 'lib/workarea/scheduler.rb', line 27 def delete current_job.try(:delete) end |
#perform ⇒ Object
22 23 24 25 |
# File 'lib/workarea/scheduler.rb', line 22 def perform delete add_job end |