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.0.104 app/models/renalware/system/api_log.rb
renalware-core-2.0.103 app/models/renalware/system/api_log.rb
renalware-core-2.0.102 app/models/renalware/system/api_log.rb
renalware-core-2.0.101 app/models/renalware/system/api_log.rb
renalware-core-2.0.100 app/models/renalware/system/api_log.rb
renalware-core-2.0.99 app/models/renalware/system/api_log.rb
renalware-core-2.0.98 app/models/renalware/system/api_log.rb
renalware-core-2.0.97 app/models/renalware/system/api_log.rb
renalware-core-2.0.96 app/models/renalware/system/api_log.rb
renalware-core-2.0.95 app/models/renalware/system/api_log.rb
renalware-core-2.0.94 app/models/renalware/system/api_log.rb
renalware-core-2.0.93 app/models/renalware/system/api_log.rb
renalware-core-2.0.92 app/models/renalware/system/api_log.rb
renalware-core-2.0.91 app/models/renalware/system/api_log.rb
renalware-core-2.0.90 app/models/renalware/system/api_log.rb
renalware-core-2.0.89 app/models/renalware/system/api_log.rb
renalware-core-2.0.88 app/models/renalware/system/api_log.rb