<commit_before>class Respondent < ActiveRecord::Base
  belongs_to :claim
  has_many :addresses, as: :addressable

  delegate :building, :street, :locality, :county, :post_code, :telephone_number,
    :building=, :street=, :locality=, :county=, :post_code=, :telephone_number=,
    to: :address, prefix: true

  delegate :building, :street, :locality, :county, :post_code, :telephone_number,
    :building=, :street=, :locality=, :county=, :post_code=, :telephone_number=,
    to: :work_address, prefix: true

  def address
    addresses.first
  end

  def work_address
    addresses.second
  end

  def addresses
    association(:addresses).tap do |p|
      2.times { p.build } if p.empty?
    end
  end
end<commit_msg>DRY up Respondent address delegation<commit_after>class Respondent < ActiveRecord::Base
  belongs_to :claim
  has_many :addresses, as: :addressable

  ADDRESS_ATTRIBUTES = %i<building street locality county post_code
                          telephone_number>.flat_map { |a| [a, :"#{a}="] }

  delegate *ADDRESS_ATTRIBUTES, to: :address, prefix: true
  delegate *ADDRESS_ATTRIBUTES, to: :work_address, prefix: true

  def address
    addresses.first
  end

  def work_address
    addresses.second
  end

  def addresses
    association(:addresses).tap do |p|
      2.times { p.build } if p.empty?
    end
  end
end
{'fraction_non_alphanumeric': 0.11169415292353824, 'fraction_numerical': 0.0014992503748125937, 'mean_word_length': 3.8194945848375452, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 4, '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': '6925286', 'n_tokens_mistral': 458, 'n_tokens_neox': 442, 'n_words': 117}