<commit_before>module Diffable
  module ClassMethods
    def diffable?
      @diffable_fields.is_a?(Array) and @diffable_fields.size > 0
    end

    def diffable_on(*fields)
      fields = fields.flatten
      unless fields.size > 0 and valid_fields?(fields)
        fail 'Please provide an Array of fields to be diffable'
      end

      @diffable_fields = fields
    end

    def diffable_fields(current = @diffable_fields)
      return [] unless diffable?

      current = [current] unless current.is_a?(Array)
      result  = []

      current.each do |field|
        if field.is_a?(Hash)
          field_key = field.keys.first
          field.values.first.each do |value|
            result << [field_key] + diffable_fields(value).flatten
          end
        else
          result << field.to_sym
        end
      end

      result
    end

    def valid_fields?(fields)<commit_msg>remove temp variable<commit_after>module Diffable
  module ClassMethods
    def diffable?
      @diffable_fields.is_a?(Array) and @diffable_fields.size > 0
    end

    def diffable_on(*fields)
      fields = fields.flatten
      unless fields.size > 0 and valid_fields?(fields)
        fail 'Please provide an Array of fields to be diffable'
      end

      @diffable_fields = fields
    end

    def diffable_fields(current = @diffable_fields)
      return [] unless diffable?

      current = [current] unless current.is_a?(Array)
      result  = []

      current.each do |field|
        if field.is_a?(Hash)
          field.values.first.each do |value|
            result << [field.keys.first] + diffable_fields(value).flatten
          end
        else
          result << field.to_sym
        end
      end

      result
    end

    def valid_fields?(fields)
{'fraction_non_alphanumeric': 0.08129619101762366, 'fraction_numerical': 0.0022740193291642978, 'mean_word_length': 2.1768953068592056, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, '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': '944125', 'n_tokens_mistral': 526, 'n_tokens_neox': 516, 'n_words': 135}