<commit_before>module Obfuscator
  class Generic
    class UnkownObfuscationTypeError < StandardError; end

    attr_accessor :model, :columns

    def scrub!(model_name = "User", columns = [])
      @model = model_name.constantize

      if columns.is_a?(Hash)
        store_types_from_column_values(columns)
        @columns = columns.keys
      else
        @columns = columns
      end

      return unless @columns.any? and @columns.map!(&:to_s)

      scrub_all_records!
    end

    private

    def model_columns_contain_given?
      (@model.columns_hash.keys | @columns).any?
    end

    def store_types_from_column_values(columns)
      columns.each do |key, value|
        instance_variable_set("@#{key}_type", value)
      end
    end

    def columns_with_obfuscated_values_hash
      result_hash = {}

      @columns.each do |column|<commit_msg>Singularizes model names passed to scrub in case of user error<commit_after>module Obfuscator
  class Generic
    class UnkownObfuscationTypeError < StandardError; end

    attr_accessor :model, :columns

    def scrub!(model_name = "User", columns = [])
      @model = model_name.singularize.constantize

      if columns.is_a?(Hash)
        store_types_from_column_values(columns)
        @columns = columns.keys
      else
        @columns = columns
      end

      return unless @columns.any? and @columns.map!(&:to_s)

      scrub_all_records!
    end

    private

    def model_columns_contain_given?
      (@model.columns_hash.keys | @columns).any?
    end

    def store_types_from_column_values(columns)
      columns.each do |key, value|
        instance_variable_set("@#{key}_type", value)
      end
    end

    def columns_with_obfuscated_values_hash
      result_hash = {}

      @columns.each do |column|
{'fraction_non_alphanumeric': 0.08478382930937675, 'fraction_numerical': 0.0, 'mean_word_length': 2.873913043478261, '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': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3679264', 'n_tokens_mistral': 565, 'n_tokens_neox': 546, 'n_words': 119}