Class: LoggingWorker::JobRun
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- LoggingWorker::JobRun
- Defined in:
- app/models/logging_worker/job_run.rb
Instance Method Summary collapse
- #completed! ⇒ Object
- #do_not_record! ⇒ Object
- #flush_log!(save_to_db = true) ⇒ Object
- #logger ⇒ Object
- #successful! ⇒ Object
Instance Method Details
#completed! ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/models/logging_worker/job_run.rb', line 31 def completed! if @do_not_record destroy! else self.successful = false if successful.nil? self.completed_at = Time.now logger # make sure we've got it flush_log!(false) save! end end |
#do_not_record! ⇒ Object
23 24 25 |
# File 'app/models/logging_worker/job_run.rb', line 23 def do_not_record! @do_not_record = true end |
#flush_log!(save_to_db = true) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'app/models/logging_worker/job_run.rb', line 12 def flush_log!(save_to_db = true) @io.rewind content = @io.read self.log += content save! if save_to_db @io.close @logger.close @io = nil @logger = nil end |
#logger ⇒ Object
7 8 9 10 |
# File 'app/models/logging_worker/job_run.rb', line 7 def logger @io ||= StringIO.new @logger ||= Logger.new(@io) end |
#successful! ⇒ Object
27 28 29 |
# File 'app/models/logging_worker/job_run.rb', line 27 def successful! self.successful = true end |