combined_attributes.rb 533 B

1234567891011121314151617181920
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Sequencer::Unit::Import::Common::Model::Lookup::CombinedAttributes < Sequencer::Unit::Import::Common::Model::Lookup::Attributes
  3. def existing_instance
  4. @existing_instance ||= begin
  5. filters = {}
  6. Array(attributes).each do |attribute|
  7. value = mapped[attribute]
  8. next if value.blank?
  9. filters[attribute] = value
  10. end
  11. if filters.present?
  12. model_class.find_by(filters)
  13. end
  14. end
  15. end
  16. end