create.rb 783 B

123456789101112131415161718192021222324252627282930
  1. # Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
  2. class Sequencer
  3. class Unit
  4. module Import
  5. module Common
  6. module Model
  7. class Create < Sequencer::Unit::Base
  8. include ::Sequencer::Unit::Import::Common::Model::Mixin::HandleFailure
  9. prepend ::Sequencer::Unit::Import::Common::Model::Mixin::Skip::Action
  10. skip_any_action
  11. uses :mapped, :model_class
  12. provides :instance, :action
  13. def process
  14. instance = model_class.new(mapped)
  15. state.provide(:instance, instance)
  16. state.provide(:action, :created)
  17. rescue => e
  18. handle_failure(e)
  19. end
  20. end
  21. end
  22. end
  23. end
  24. end
  25. end