<commit_before>module Mongoid
  module Giza
    # Represents an Sphinx index attribute
    class Attribute
      class << self;

        # Defines the array of currently supported Sphix attribute types
        def types
          [:uint, :bool, :bigint, :timestamp, :str2ordinal,
            :float, :multi, :string, :json, :str2wordcount]
        end
      end

      attr_accessor :name, :type, :block

      # Creates a new attribute with name, type and an optional block
      #
      # If a block is given then it will be evaluated for each instance of the class being indexed
      # and the resulting value will be the attribute value.
      # Otherwise the attribute value will be the value of the corresponding object field
      #
      # Parameters::
      #   * [ +Symbol+ +name+ ] the name of the attribute
      #   * [ +Symbol+ +type+ ] the type of the attribute. Must be one of the types defined in +Mongoid+::+Giza+::+Attribute+::+types+
      def initialize(name, type, &block)
        raise TypeError,
          "attribute type not supported. " \
          "It must be one of the following: " \
          "#{self.class.types.join(", ")}" unless self.class.types.include? type
        @name = name
        @type = type
        @block = block
      end
    end
  end
end
<commit_msg>Use a constant to define the accepted types by sphinx<commit_after>module Mongoid
  module Giza
    # Represents an Sphinx index attribute
    class Attribute

      # Defines the array of currently supported Sphix attribute types
      TYPES = [
        :uint, :bool, :bigint, :timestamp, :str2ordinal,
        :float, :multi, :string, :json, :str2wordcount
      ]

      attr_accessor :name, :type, :block

      # Creates a new attribute with name, type and an optional block
      #
      # If a block is given then it will be evaluated for each instance of the class being indexed
      # and the resulting value will be the attribute value.
      # Otherwise the attribute value will be the value of the corresponding object field
      #
      # Parameters::
      #   * [ +Symbol+ +name+ ] the name of the attribute
      #   * [ +Symbol+ +type+ ] the type of the attribute. Must be one of the types defined in +Mongoid+::+Giza+::+Attribute+::+types+
      def initialize(name, type, &block)
        raise TypeError,
          "attribute type not supported. " \
          "It must be one of the following: " \
          "#{Mongoid::Giza::Attribute::TYPES.join(", ")}" unless Mongoid::Giza::Attribute::TYPES.include? type
        @name = name
        @type = type
        @block = block
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.08844834159359512, 'fraction_numerical': 0.0015249714067861228, 'mean_word_length': 2.385806451612903, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5190615', 'n_tokens_mistral': 728, 'n_tokens_neox': 724, 'n_words': 296}