You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: permalink_generator.rb
    path of file: ./repos/openfoodnetwork/app/models/concerns
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

# Finds a unique permalink for a new or updated record.
# It considers soft-deleted records which are ignored by Spree.
# Spree's work:
# https://github.c
    
    def find_available_value(existing, requested)
      return requested unless existing.include?(requested)

      used_indices = existing.map do |p|
        p.slice!(/^#{requested}/)
        p.match(/^\d+$/).to_s.to_i
      end
      options = (1..used_indices.length + 1).to_a - used_indices
      requested + options.first.to_s
    end