Sha256: 8bfd5988b802d262c6e28a6a3d8682b56a9c889f1bc9666110acc7252369fece

Contents?: true

Size: 739 Bytes

Versions: 77

Compression:

Stored size: 739 Bytes

Contents

# frozen_string_literal: true

require_dependency "renalware/system"

module Renalware
  module System
    class APILog < ApplicationRecord
      validates :identifier, presence: true
      validates :status, presence: true
      STATUS_WORKING = "working"
      STATUS_DONE = "done"
      STATUS_ERROR = "error"

      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
    end
  end
end

Version data entries

77 entries across 77 versions & 1 rubygems

Version Path
renalware-core-2.1.1 app/models/renalware/system/api_log.rb
renalware-core-2.1.0 app/models/renalware/system/api_log.rb
renalware-core-2.0.167 app/models/renalware/system/api_log.rb
renalware-core-2.0.166 app/models/renalware/system/api_log.rb
renalware-core-2.0.165 app/models/renalware/system/api_log.rb
renalware-core-2.0.164 app/models/renalware/system/api_log.rb
renalware-core-2.0.163 app/models/renalware/system/api_log.rb
renalware-core-2.0.162 app/models/renalware/system/api_log.rb
renalware-core-2.0.161 app/models/renalware/system/api_log.rb
renalware-core-2.0.160 app/models/renalware/system/api_log.rb
renalware-core-2.0.159 app/models/renalware/system/api_log.rb
renalware-core-2.0.158 app/models/renalware/system/api_log.rb
renalware-core-2.0.157 app/models/renalware/system/api_log.rb
renalware-core-2.0.156 app/models/renalware/system/api_log.rb
renalware-core-2.0.155 app/models/renalware/system/api_log.rb
renalware-core-2.0.153 app/models/renalware/system/api_log.rb
renalware-core-2.0.152 app/models/renalware/system/api_log.rb
renalware-core-2.0.151 app/models/renalware/system/api_log.rb
renalware-core-2.0.149 app/models/renalware/system/api_log.rb
renalware-core-2.0.148 app/models/renalware/system/api_log.rb