<commit_before>module SetProfileRegionFromCityState

  module ClassMethods
    def set_profile_region_from_city_state
      before_save :region_from_city_and_state

      include InstanceMethods
    end
  end

  module InstanceMethods

    def city=(value)
      self.data[:city] = value
      @change_region = true
    end

    def state=(value)
      self.data[:state] = value
      @change_region = true
    end

    def region_from_city_and_state
      if @change_region
        s = State.find_by_name self.state
        c = s.children.find_by_name self.city
        self.region = c
      end
    end

  end

end
<commit_msg>Fix module methods' overwriting<commit_after>module SetProfileRegionFromCityState

  module ClassMethods
    def set_profile_region_from_city_state
      before_save :region_from_city_and_state

      include InstanceMethods
      alias_method_chain :city=, :region
      alias_method_chain :state=, :region
    end
  end

  module InstanceMethods

    def city_with_region=(value)
      self.city_without_region = value
      @change_region = true
    end

    def state_with_region=(value)
      self.state_without_region = value
      @change_region = true
    end

    def region_from_city_and_state
      if @change_region
        s = State.find_by_name self.state
        c = s.children.find_by_name self.city
        self.region = c
      end
    end

  end

end

{'fraction_non_alphanumeric': 0.05075053609721229, 'fraction_numerical': 0.0, 'mean_word_length': 2.6842105263157894, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1677690', 'n_tokens_mistral': 436, 'n_tokens_neox': 425, 'n_words': 97}