Class: ActiveJob::Notificare::ProgressHandle
- Inherits:
-
Object
- Object
- ActiveJob::Notificare::ProgressHandle
- Defined in:
- lib/active_job/notificare/progress_handle.rb
Instance Method Summary collapse
- #advance!(by = 1) ⇒ Object
-
#initialize(job_id) ⇒ ProgressHandle
constructor
A new instance of ProgressHandle.
- #total(n) ⇒ Object
Constructor Details
#initialize(job_id) ⇒ ProgressHandle
Returns a new instance of ProgressHandle.
4 5 6 |
# File 'lib/active_job/notificare/progress_handle.rb', line 4 def initialize(job_id) @job_id = job_id end |
Instance Method Details
#advance!(by = 1) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/active_job/notificare/progress_handle.rb', line 15 def advance!(by = 1) rows = Execution.where(job_id: @job_id).update_all("progress_current = progress_current + #{by.to_i}") if rows == 0 Rails.logger.debug { "[notificare] progress.advance! called before execution row exists for job_id=#{@job_id}" } end end |
#total(n) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/active_job/notificare/progress_handle.rb', line 8 def total(n) rows = Execution.where(job_id: @job_id).update_all(progress_total: n) if rows == 0 Rails.logger.debug { "[notificare] progress.total called before execution row exists for job_id=#{@job_id}" } end end |