<commit_before>module DataMapper
  module Relation
    class Aliases

      class Attribute < Struct.new(:field, :prefix, :aliased)

        CACHE = {}

        def self.build(field, prefix, aliased = false)
          key = "#{field}-#{prefix}-#{aliased.inspect}"
          CACHE.fetch(key) {
            CACHE[key] = Attribute.new(field, prefix, aliased)
          }
        end

        attr_reader :name

        private :field=, :prefix=, :aliased=

        def initialize(field, prefix, aliased)
          super
          @name = aliased ? :"#{prefix}_#{field}" : field.to_sym
        end

      end # struct Attribute

    end # class Aliases
  end # module Relation
end # module DataMapper<commit_msg>Add docs for DataMapper::Relation::Aliases::Attribute<commit_after>module DataMapper
  module Relation
    class Aliases

      class Attribute < Struct.new(:field, :prefix, :aliased)

        CACHE = {}

        # Build and cache a new {Attribute} instance
        #
        # @param [#to_sym] field
        #   the attribute's field name
        #
        # @param [#to_sym] prefix
        #   the prefix to use for aliasing
        #
        # @param [Boolean] aliased
        #   true if this attribute is aliased, false otherwise
        #
        # @return [Attribute]
        #
        # @api private
        def self.build(field, prefix, aliased = false)
          key = "#{field}-#{prefix}-#{aliased.inspect}"
          CACHE.fetch(key) {
            CACHE[key] = Attribute.new(field, prefix, aliased)
          }
        end

        # Return this attribute's name
        #
        # @return [Symbol]
        #
        # @api private
        attr_reader :name

        private :field=, :prefix=, :aliased=

        # Initialize a new instance
        #
        # @param [#to_sym] field
        #   the attribute's field name
        #
        # @param [#to_sym] prefix
        #   the prefix to use for aliasing
        #
        # @param [Boolean] aliased
        #   true if this attribute is aliased, false otherwise
        #
        # @return [undefined
        #
        # @api private
        def initialize(field, prefix, aliased)
          super
          @name = aliased ? :"#{prefix}_#{field}" : field.to_sym
        end

      end # struct Attribute

    end # class Aliases
  end # module Relation
end # module DataMapper
{'fraction_non_alphanumeric': 0.10157246068848279, 'fraction_numerical': 0.0, 'mean_word_length': 1.7890995260663507, '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': '4814432', 'n_tokens_mistral': 677, 'n_tokens_neox': 654, 'n_words': 189}