sub_object.rb 963 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Sequencer::Unit::Import::Zendesk::SubSequence::SubObject < Sequencer::Unit::Base
  3. include ::Sequencer::Unit::Import::Zendesk::SubSequence::Base
  4. uses :resource, :instance, :user_id, :model_class, :action, :field_map
  5. def self.inherited(subclass)
  6. super
  7. subclass.prepend(::Sequencer::Unit::Import::Common::Model::Mixin::Skip::Action)
  8. subclass.skip_action(:skipped, :failed)
  9. end
  10. def process
  11. resource_iteration do |sub_resource|
  12. ::Sequencer.process(sequence_name,
  13. parameters: default_params.merge(
  14. resource: sub_resource
  15. ),)
  16. end
  17. end
  18. private
  19. def collection_provider
  20. resource
  21. end
  22. def default_params
  23. super.merge(
  24. instance: instance,
  25. user_id: user_id,
  26. model_class: model_class,
  27. field_map: field_map,
  28. )
  29. end
  30. end