scinote-web/app/services/repositories/restore_repository_service.rb

23 lines
562 B
Ruby
Raw Normal View History

# frozen_string_literal: true
module Repositories
class RestoreRepositoryService < ArchiveRepositoryBaseService
def call
return self unless valid?
ActiveRecord::Base.transaction do
@repositories.each do |repository|
repository.restore!(@user)
log_activity(:restore_inventory, repository)
end
2021-01-08 15:05:05 +08:00
rescue ActiveRecord::RecordInvalid
@errors[:restoring_error] = I18n.t('repositories.restore_inventories.unsuccess_flash')
raise ActiveRecord::Rollback
end
self
end
end
end