<commit_before>module DataMapper
  class AliasSet
    include Enumerable

    attr_reader :prefix
    attr_reader :attributes
    attr_reader :excluded

    # @api private
    def initialize(prefix, attributes = Mapper::AttributeSet.new, excluded = [])
      @prefix     = prefix
      @attributes = attributes
      @excluded   = excluded
      @index      = attributes.alias_index(prefix, excluded)
    end

    # @api private
    def each(&block)
      return to_enum unless block_given?
      @index.each(&block)
      self
    end

    # @api private
    def exclude(*names)
      self.class.new(prefix, attributes, excluded.dup.concat(names))
    end

    # @api private
    def merge(other)
      attributes = @attributes.merge(other.attributes)
      excluded   = @excluded.dup.concat(other.excluded)
      self.class.new(prefix, attributes, excluded)
    end

    # @api private
    def to_hash
      @index
    end

  end # class AliasSet
end # module DataMapper
<commit_msg>Add docs for AliasSet<commit_after>module DataMapper
  # Represent a set of attribute aliases used in joined relations
  #
  class AliasSet
    include Enumerable

    # Prefix used for aliasing
    #
    # @api private
    attr_reader :prefix

    # AttributeSet instance from a mapper
    #
    # @api private
    attr_reader :attributes

    # An array of attributes that should be excluded from aliasing
    #
    # @api private
    attr_reader :excluded

    # Initialize an alias set instance
    #
    # @param [Symbol] prefix used for aliasing
    # @param [DataMapper::Mapper::AttributeSet] attributes
    # @param [Array] list of excluded attribute names
    #
    # @return [undefined]
    #
    # @api private
    def initialize(prefix, attributes = Mapper::AttributeSet.new, excluded = [])
      @prefix     = prefix
      @attributes = attributes
      @excluded   = excluded
      @index      = attributes.alias_index(prefix, excluded)
    end

    # Iterate on alias index
    #
    # @api private
    def each(&block)
      return to_enum unless block_given?
      @index.each(&block)
      self
    end

    # Returns a new alias set with excluded attribute names
    #
    # @return [DataMapper::AliasSet]
    #
    # @api private
    def exclude(*names)
      self.class.new(prefix, attributes, excluded.dup.concat(names))
    end

    # Returns a new alias set merged with the given one
    #
    # @return [DataMapper::AliasSet]
    #
    # @api private
    def merge(other)
      attributes = @attributes.merge(other.attributes)
      excluded   = @excluded.dup.concat(other.excluded)
      self.class.new(prefix, attributes, excluded)
    end

    # Returns hash representation of the alias set
    #
    # @return [Hash]
    #
    # @api private
    def to_hash
      @index
    end

  end # class AliasSet
end # module DataMapper

{'fraction_non_alphanumeric': 0.08271735304470257, 'fraction_numerical': 0.0, 'mean_word_length': 2.512978986402967, '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': '3684830', 'n_tokens_mistral': 828, 'n_tokens_neox': 808, 'n_words': 241}