<commit_before>require 'smtpapi'

module SendGrid
  class Recipient
    class NoAddress < StandardError; end

    attr_reader :address, :substitutions

    def initialize(address)
      @address = address
      @substitutions = {}

      raise NoAddress, 'Recipient address cannot be nil' if @address.nil?
    end

    def add_substitution(key, value)
      substitutions[key.to_sym] = value
    end

    def add_to_smtpapi(smtpapi)
      smtpapi.add_to(@address)

      @substitutions.each do |key, value|
        smtpapi.add_substitution(key, value)
      end
    end
  end
end<commit_msg>Bug with substitution calling in template and change to association<commit_after>require 'smtpapi'

module SendGrid
  class Recipient
    class NoAddress < StandardError; end

    attr_reader :address, :substitutions

    def initialize(address)
      @address = address
      @substitutions = {}

      raise NoAddress, 'Recipient address cannot be nil' if @address.nil?
    end

    def add_substitution(key, value)
      substitutions[key] = value
    end

    def add_to_smtpapi(smtpapi)
      smtpapi.add_to(@address)

      @substitutions.each do |key, value|
        smtpapi.add_substitution(key, [value])
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.07554833468724614, 'fraction_numerical': 0.0, 'mean_word_length': 3.013029315960912, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2611786', 'n_tokens_mistral': 413, 'n_tokens_neox': 380, 'n_words': 104}