Class: Renalware::System::APILog
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Renalware::System::APILog
- Defined in:
- app/models/renalware/system/api_log.rb
Constant Summary collapse
- STATUS_WORKING =
"working"
- STATUS_DONE =
"done"
- STATUS_ERROR =
"error"
Class Method Summary collapse
Class Method Details
.with_log(identifier, **args) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/models/renalware/system/api_log.rb', line 14 def self.with_log(identifier, **args) log = create!(identifier: identifier, status: STATUS_WORKING, **args) yield(log) if block_given? log.update!(status: STATUS_DONE) log rescue StandardError => e log.update( status: STATUS_ERROR, error: "#{$ERROR_INFO}\nBacktrace:\n\t#{e.backtrace.join("\n\t")}" ) raise e end |