0
  D   ˆl–Ðz¾”ªC]Šq@=q¦®41hß�þ[ Öq°9 €!½!üÿÍƒOÌ_�uÐb&=LyZËcõÌË Ê    # Copyright (C) 2012-2026 Zammad Foundation, https://zammad-foundation.org/

class Sequencer::Unit::Import::Common::Model::Lookup::Attributes < Sequencer::Unit::Base
  include ::Sequencer::Unit::Import::Common::Model::Mixin::HandleFailure
  prepend ::Sequencer::Unit::Import::Common::Model::Mixin::Skip::Action

  skip_action :skipped, :failed

  uses :mapped, :model_class
  provides :instance

  def process
    return if state.provided?(:instance)
    return if existing_instance.blank?

    state.provide(:instance, existing_instance)
  end

  private

  def attribute
    raise "Missing implementation of '#{__method__}' method for '#{self.class.name}'"
  end

  def attributes
    # alias or alias_method won't work if attribute method
    # is overwritten in inheriting sub-class
    attribute
  end

  def existing_instance
    @existing_instance ||= begin
      Array(attributes).find do |attribute|

        value = mapped[attribute]
        next if value.blank?

        existing_instance = lookup(
          attribute: attribute,
          value:     value
        )

        next if existing_instance.blank?

        # https://stackoverflow.com/a/24901650/7900866
        break existing_instance
      end
    end
  end

  def lookup(attribute:, value:)
    return model_class.identify(value) if model_class.respond_to?(:identify)

    lookup_find_by(attribute, value)
  end

  def lookup_find_by(attribute, value)
    model_class.find_by(attribute => value)
  end
end
     ˆÊÉÍ574ÈÌË >    ‹      ÅUÑnÚ0}ïWx~Ø[r	P:Q“©#HC£€(Ó4M{0±C,;²Œ}ý*›@�n/ñ�}lŸsìëKÞD£îôë¸‡>NhüùÃ ßEØøÒèDÓ¨húµ  7Ä§Öm€õzí¯¾Òs˜N µyÖcµˆ­Ï,Ãá)ûÂDRN™k±Âf<ìKÆ • PKkãõ} Lå—,÷Ï•Ÿ?Vªp0Ï˜l�vÛmÄ5„,–øŠKÛ ³œ¹Ëóª»Œ¯DìV×bÅ5�Š†#;fd¦Ø¦$ürŽÃÖ*:Ûr,C›¢ÍÄ\v°U‰ÈçÈè¸ƒAÄJ˜eT.ü¹H0¢™íàoýîè»Ã�MËÙ!¡(Õ<éà÷ÝÎð~Ô‰p8¤9'@�cæ‡j,Ê‰àì$ø©?‰Ÿ§Œ*LÄM¬Ea…’ÏPp¥Æ*3uZo�‚T¢*{ÉÿfÆøaÒN£þ¤²„•K<³û×G�Ã1Õ�"¡yl•Þì¬¨x½•3SÜïÑN¨óÔâ!E^àÎR.¤ZËCƒœùG­™	éR¹üRüƒS½VoyAÝ«(hµë·� ºGäÓß’OTÆ¸>ä~êXÝµ]f¥Û»àE�×¨¡à®Ý|wRÁ5ì?_A›b¡�‚]p¾‚»WUpÁZns‡U{�#¸Æ%ºD€¬r j_?Î|aW lk�ªØþ¬p’Ï       ˆÊÉÍ597ÈÌË U    ‹      Í–_OÛ0ÅßùžöÖÜ
�fbÓªµ¥¢™`šöàÆnbpìÈ¾¥…O?7)#B°?RÕíÉ¾Î‰s~ÇIìðM|ÑO¾NÎÉ§d4$“/†ƒ>¡-€«ƒ>@œÄõ…nÐî œ�)¡9by°\.ƒåA`lÉ%äX¨.8´2Å€#§Ñ^¸‹öH˜Æ}KB”¨D4Ð\¬ˆ™0t’?s¹˜)™> 7…'4ŸK%.
ä.H�)ýƒ¸I]Ë9õ¨îÂÂYp9³nØs©•%BÁ0¿a+Xè’¥·‚ƒ2)Sò�¡4†PÛñaã0œ~¿6ÞùLz/UtlVy]wmbNî¼.Ó=Š¦¤Q(‹Œ8›ö(ÈÔh3Åôm�É9%La�~ô/¾{`¾¾;
É­˜÷èû~o|zÑ‹i4f…�½¬yÍ�†Ì!)—s)ø«âi-žÊ‡×'ŒkM,ê$<î“<b55Ê•Ì³z‚Ü6Uµ„ÿ.n3ŒÉÙåù8‰—u$|=Å“»¹ä4šx½FK+R4ö~Kíñ­ž¹òô±$h+³iDH‹¼¨ü‹¤P¬°™Tr�¼˜ÑG£ñŠY-uæ‚G£gM×Ïlî·÷Û­ö»Öþ!é�´�	yMt?ïŠgý“kõ§ÓŠ¥Qlƒ£³K¡ÊX2e²š¤YngMŽwÆ2ò_ÊhXqüìn‡áp·B/ž(êbGÁÑÎ8q]!ÔívÜïîMRX™¯ší|Ñ¿òþ‡;löôªcGõyé‡„Ì’	    6   ˆl–Ãa¾”Êj"TŒ‚ã`S�ÿ�þd#ë6I$n7ËExÏÏƒe±?ÎÇÍÌ É    /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/* RAII class for executing arbitrary actions at scope end. */

#ifndef mozilla_ScopeExit_h
#define mozilla_ScopeExit_h

/*
 * See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4189.pdf for a
 * standards-track version of this.
 *
 * Error handling can be complex when various actions need to be performed that
 * need to be undone if an error occurs midway. This can be handled with a
 * collection of boolean state variables and gotos, which can get clunky and
 * error-prone:
 *
 * {
 *   if (!a.setup())
 *       goto fail;
 *   isASetup = true;
 *
 *   if (!b.setup())
 *       goto fail;
 *   isBSetup = true;
 *
 *   ...
 *   return true;
 *
 *   fail:
 *     if (isASetup)
 *         a.teardown();
 *     if (isBSetup)
 *         b.teardown();
 *     return false;
 *  }
 *
 * ScopeExit is a mechanism to simplify this pattern by keeping an RAII guard
 * class that will perf