mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-14 05:05:55 +08:00
24 lines
698 B
Ruby
24 lines
698 B
Ruby
# frozen_string_literal: true
|
|
|
|
class MyModuleStatusConsequencesJob < ApplicationJob
|
|
queue_as :high_priority
|
|
|
|
def perform(my_module, my_module_status_consequences)
|
|
error_raised = false
|
|
my_module.transaction do
|
|
my_module_status_consequences.each do |consequence|
|
|
consequence.call(my_module)
|
|
end
|
|
my_module.update!(status_changing: false)
|
|
rescue StandardError => e
|
|
Rails.logger.error(e.message)
|
|
Rails.logger.error(e.backtrace.join("\n"))
|
|
error_raised = true
|
|
end
|
|
if error_raised
|
|
my_module.my_module_status = my_module.changing_from_my_module_status
|
|
my_module.status_changing = false
|
|
my_module.save!
|
|
end
|
|
end
|
|
end
|