<commit_before>module HstoreRadioButtons
  class Configuration
    def self.from_yaml(model, yaml_file_location = './config/hstore_radio_button_sets.yml')
      if yaml_exists?(yaml_file_location)
        button_sets = YAML.load(config_file(yaml_file_location))[model.to_s.downcase].keys
        button_sets.each do |button_set|
          model.send(:define_method, button_set.to_sym) {
            hstore_data_proxy[button_set]
          }
          model.send(:define_method, "#{button_set}=".to_sym) {|value|
            hstore_data_proxy[button_set] = value
          }
        end
      end
    end

    private

    def self.config_file(yaml_file_location)
      File.open(yaml_file_location)
    end

    def self.yaml_exists?(yaml_file_location)
      File.exists?(yaml_file_location)
    end
  end
end<commit_msg>Moving the build to an instance method where should have been to begin with.<commit_after>module HstoreRadioButtons
  class Configuration
    def self.from_yaml(model, yaml_file_location = './config/hstore_radio_button_sets.yml')
      self.new._from_yaml(model, yaml_file_location)
    end

    def _from_yaml(model, yaml_file_location)
      self.yaml_file_location = yaml_file_location
      self.model = model

      if yaml_exists?
        button_definitions_from_yaml.each do |button_definition|
          model.send(:define_method, button_definition.to_sym) {
            hstore_data_proxy[button_definition]
          }
          model.send(:define_method, "#{button_definition}=".to_sym) {|value|
            hstore_data_proxy[button_definition] = value
          }
        end
      end
    end

  private
    attr_accessor :model, :yaml_file_location
    def config_file
      File.open(yaml_file_location)
    end

    def yaml_exists?
      File.exists?(yaml_file_location)
    end

    def button_definitions_from_yaml
      YAML.load(config_file)[model.to_s.downcase].keys
    end
  end
end
{'fraction_non_alphanumeric': 0.07939802802283343, 'fraction_numerical': 0.0, 'mean_word_length': 2.991718426501035, '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': '1071429', 'n_tokens_mistral': 618, 'n_tokens_neox': 600, 'n_words': 101}