external_sync.rb 755 B

12345678910111213141516171819202122232425262728293031
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Sequencer::Unit::Import::Common::Model::Lookup::ExternalSync < Sequencer::Unit::Base
  3. include ::Sequencer::Unit::Import::Common::Model::Mixin::HandleFailure
  4. prepend ::Sequencer::Unit::Import::Common::Model::Mixin::Skip::Action
  5. skip_action :skipped
  6. uses :remote_id, :model_class, :external_sync_source
  7. provides :instance
  8. def process
  9. return if entry.blank?
  10. state.provide(:instance) do
  11. model_class.find(entry.o_id)
  12. end
  13. rescue => e
  14. handle_failure(e)
  15. end
  16. private
  17. def entry
  18. @entry ||= ::ExternalSync.find_by(
  19. source: external_sync_source,
  20. source_id: remote_id,
  21. object: model_class.name,
  22. )
  23. end
  24. end