<commit_before>class BusinessOffice < ActiveRecord::Base
  belongs_to :company, :inverse_of => 'business_offices'

  nostalgic_for :name

  validates :name, :presence => true
  validates :prefecture_code, :presence => true

  before_save :set_prefecture_name
  
  def address
    [address1, address2].join
  end

  private

  def set_prefecture_name
    p = TaxJp::Prefecture.find_by_code(self.prefecture_code)
    self.prefecture_name = p ? p.name : ''
  end
end<commit_msg>refactor<commit_after>class BusinessOffice < ActiveRecord::Base
  belongs_to :company, :inverse_of => 'business_offices'

  nostalgic_for :name
  validates :name, :presence => true, :uniqueness => {:scope  => :company_id}

  validates :prefecture_code, :presence => true

  before_save :set_prefecture_name

  def address
    [address1, address2].compact.join
  end

  private

  def set_prefecture_name
    p = TaxJp::Prefecture.find_by_code(self.prefecture_code)
    self.prefecture_name = p ? p.name : ''
  end
end
{'fraction_non_alphanumeric': 0.09778225806451613, 'fraction_numerical': 0.004032258064516129, 'mean_word_length': 4.516666666666667, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '4013083', 'n_tokens_mistral': 364, 'n_tokens_neox': 336, 'n_words': 70}