2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
2017-08-14 11:56:23 +00:00
|
|
|
class Sequencer
|
|
|
|
class Unit
|
|
|
|
module Import
|
|
|
|
module Common
|
|
|
|
module Model
|
|
|
|
class Create < Sequencer::Unit::Base
|
|
|
|
include ::Sequencer::Unit::Import::Common::Model::Mixin::HandleFailure
|
2017-12-21 11:19:30 +00:00
|
|
|
prepend ::Sequencer::Unit::Import::Common::Model::Mixin::Skip::Action
|
2017-09-01 12:02:12 +00:00
|
|
|
|
2017-12-21 11:19:30 +00:00
|
|
|
skip_any_action
|
2017-08-14 11:56:23 +00:00
|
|
|
|
|
|
|
uses :mapped, :model_class
|
2017-12-21 11:19:30 +00:00
|
|
|
provides :instance, :action
|
2017-08-14 11:56:23 +00:00
|
|
|
|
|
|
|
def process
|
|
|
|
instance = model_class.new(mapped)
|
2021-08-12 12:04:45 +00:00
|
|
|
|
2017-08-14 11:56:23 +00:00
|
|
|
state.provide(:instance, instance)
|
2017-12-21 11:19:30 +00:00
|
|
|
state.provide(:action, :created)
|
2017-08-14 11:56:23 +00:00
|
|
|
rescue => e
|
|
|
|
handle_failure(e)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|