Class: Jobbr::Run
- Inherits:
-
Object
- Object
- Jobbr::Run
- Includes:
- Mongoid::Document, Mongoid::Timestamps
- Defined in:
- app/models/jobbr/run.rb
Instance Method Summary collapse
- #messages(limit = 1000) ⇒ Object
- #next ⇒ Object
- #previous ⇒ Object
- #progress=(progress) ⇒ Object
- #result=(result) ⇒ Object
- #run_time ⇒ Object
Instance Method Details
#messages(limit = 1000) ⇒ Object
41 42 43 44 |
# File 'app/models/jobbr/run.rb', line 41 def (limit = 1000) limit = [.length, limit].min [-limit..-1] end |
#next ⇒ Object
32 33 34 35 |
# File 'app/models/jobbr/run.rb', line 32 def next return nil if index == 0 @next ||= Run.for_job(job).all[index - 1] end |
#previous ⇒ Object
37 38 39 |
# File 'app/models/jobbr/run.rb', line 37 def previous @previous ||= Run.for_job(job).all[index + 1] end |
#progress=(progress) ⇒ Object
51 52 53 54 |
# File 'app/models/jobbr/run.rb', line 51 def progress=(progress) write_attribute(:progress, progress) save! end |
#result=(result) ⇒ Object
46 47 48 49 |
# File 'app/models/jobbr/run.rb', line 46 def result=(result) write_attribute(:result, result) save! end |
#run_time ⇒ Object
24 25 26 27 28 29 30 |
# File 'app/models/jobbr/run.rb', line 24 def run_time @run_time ||= if finished_at && started_at finished_at - started_at else nil end end |