Sha256: 853326367be8cfd2657ce8863c244841727274f68a5d6f00b436f84bc2598e44
Contents?: true
Size: 740 Bytes
Versions: 9
Compression:
Stored size: 740 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
9 entries across 9 versions & 1 rubygems