mirror of
https://github.com/zammad/zammad
synced 2026-05-24 09:48:36 +00:00
30 lines
704 B
Ruby
30 lines
704 B
Ruby
# Copyright (C) 2012-2026 Zammad Foundation, https://zammad-foundation.org/
|
|
|
|
class Sequencer::Unit::Import::Common::Model::Save < Sequencer::Unit::Base
|
|
prepend ::Sequencer::Unit::Import::Common::Model::Mixin::Skip::Action
|
|
include ::Sequencer::Unit::Import::Common::Model::Mixin::HandleFailure
|
|
|
|
uses :instance, :action, :dry_run
|
|
provides :instance
|
|
|
|
skip_action :skipped, :failed, :unchanged
|
|
|
|
def process
|
|
return if dry_run
|
|
return if instance.blank?
|
|
|
|
save!
|
|
end
|
|
|
|
def save!
|
|
BulkImportInfo.enable
|
|
instance.save!
|
|
rescue => e
|
|
handle_failure(e)
|
|
|
|
# unset instance if something went wrong
|
|
state.provide(:instance, nil)
|
|
ensure
|
|
BulkImportInfo.disable
|
|
end
|
|
end
|