<commit_before># frozen_string_literal: true

require 'dry/equalizer'

require 'rom/initializer'
require 'rom/support/memoizable'
require 'rom/types'

module ROM
  # Schema attributes provide meta information about types and an API
  # for additional operations. This class can be extended by adapters to provide
  # database-specific features. In example rom-sql provides SQL::Attribute
  # with more features like creating SQL expressions for queries.
  #
  # Schema attributes are accessible through canonical relation schemas and
  # instance-level schemas.
  #
  # @api public
  class Attribute
    include Dry::Equalizer(:type, :options)
    include Memoizable

    extend Initializer

    # @!attribute [r] type
    #   @return [Dry::Types::Nominal, Dry::Types::Sum, Dry::Types::Constrained] The attribute's type object
    param :type

    # @!attribute [r] type
    #   @return [Symbol] Attribute name. This is the canonical name used in the datastore.
    option :name, optional: true, type: Types::Strict::Symbol

    # @!attribute [r] type
    #   @return [Symbol, nil] Alias to use instead of attribute name
    option :alias, optional: true, type: Types::Strict::Symbol.optional

    # @api private
    def [](value = Undefined)
      type[value]
    end

    # Return true if this attribute type is a primary key
    #<commit_msg>Improve docs for name attribute option<commit_after># frozen_string_literal: true

require 'dry/equalizer'

require 'rom/initializer'
require 'rom/support/memoizable'
require 'rom/types'

module ROM
  # Schema attributes provide meta information about types and an API
  # for additional operations. This class can be extended by adapters to provide
  # database-specific features. In example rom-sql provides SQL::Attribute
  # with more features like creating SQL expressions for queries.
  #
  # Schema attributes are accessible through canonical relation schemas and
  # instance-level schemas.
  #
  # @api public
  class Attribute
    include Dry::Equalizer(:type, :options)
    include Memoizable

    extend Initializer

    # @!attribute [r] type
    #   @return [Dry::Types::Nominal, Dry::Types::Sum, Dry::Types::Constrained] The attribute's type object
    param :type

    # @!attribute [r] name
    #
    # Return the canonical name of this attribute name
    #
    # This *always* returns the name that is used in the datastore, even when
    # an attribute is aliased
    #
    # @example
    #   class Users < ROM::Relation[:memory]
    #     schema do
    #       attribute :user_id, Types::Integer, alias: :id
    #       attribute :email, Types::String
    #     end
    #   end
    #
    #   users[:user_id].name
    #   # => :user_id
    #
    #   users[:email].name
    #   # => :email
    #
    # @return [Symbol]
    #
    # @api public
    option :name, optional: true, type: Types::Strict::Symbol

    # @!attribute [r] type
    #   @return [Symbol, nil] Alias to use instead of attribute name
    option :alias, optional: true, type: Types::Strict::Symbol.optional

    # @api private
    def [](value = Undefined)
      type[value]
    end

    # Return true if this attribute type is a primary key
    #
{'fraction_non_alphanumeric': 0.09379918161787851, 'fraction_numerical': 0.0, 'mean_word_length': 3.187088274044796, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 5, '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': '4088384', 'n_tokens_mistral': 923, 'n_tokens_neox': 897, 'n_words': 329}