# frozen_string_literal: true

module CreateReleasableJobs
  extend ActiveSupport::Concern

  def after_create(releasable)
    if headshots?(releasable)
      AddHeadshotCollectionUidToProjectJob.perform_later(releasable.project)
    end
    SetTagsForReleasableJob.perform_later(releasable)
    if releasable.contract_template.present?
      AttachContractToReleasableJob.perform_later(releasable)
    end
  end

  private

  def headshots?(releasable)
    [AppearanceRelease, TalentRelease].include?(releasable.class)
  end
end
