skip.rb 809 B

123456789101112131415161718192021222324252627282930
  1. # Copyright (C) 2012-2025 Zammad Foundation, https://zammad-foundation.org/
  2. class Sequencer::Unit::Import::Zendesk::ObjectAttribute::Skip < Sequencer::Unit::Base
  3. uses :field_map, :model_class, :resource, :sanitized_name
  4. provides :action
  5. # Skip fields which already exists and not editable.
  6. def process
  7. attribute = object_attribute_for_name
  8. return if !attribute || attribute.editable
  9. field_map[model_class.name] ||= {}
  10. field_map[model_class.name][ resource['key'] ] = sanitized_name
  11. logger.info { "Skipping. Default field '#{attribute}' found for field '#{sanitized_name}'." }
  12. state.provide(:action, :skipped)
  13. end
  14. private
  15. def object_attribute_for_name
  16. ObjectManager::Attribute.get(
  17. object: model_class.name,
  18. name: sanitized_name
  19. )
  20. end
  21. end