config.rb 954 B

12345678910111213141516171819202122232425262728293031
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Sequencer::Unit::Import::Kayako::ObjectAttribute::Config < Sequencer::Unit::Base
  3. prepend ::Sequencer::Unit::Import::Common::Model::Mixin::Skip::Action
  4. include ::Sequencer::Unit::Import::Common::Model::Mixin::HandleFailure
  5. skip_any_action
  6. uses :resource, :sanitized_name, :model_class, :default_language
  7. provides :config
  8. def process
  9. attribute_config = attribute_type.config
  10. state.provide(:config) do
  11. {
  12. object: model_class.to_s,
  13. name: sanitized_name,
  14. }.merge(attribute_config)
  15. end
  16. rescue => e
  17. logger.error "The custom field type '#{resource['type']}' can not be mapped to an internal field."
  18. handle_failure(e)
  19. end
  20. private
  21. def attribute_type
  22. "Sequencer::Unit::Import::Kayako::ObjectAttribute::AttributeType::#{resource['type'].capitalize}".constantize.new(resource, default_language)
  23. end
  24. end