module ActiveRecord::Attributes::ClassMethods

def _default_attributes # :nodoc:

:nodoc:
def _default_attributes # :nodoc:
  @default_attributes ||= begin
    attributes_hash = with_connection do |connection|
      columns_hash.transform_values do |column|
        ActiveModel::Attribute.from_database(column.name, column.default, type_for_column(connection, column))
      end
    end
    attribute_set = ActiveModel::AttributeSet.new(attributes_hash)
    apply_pending_attribute_modifications(attribute_set)
    attribute_set
  end
end

def define_attribute(

+cast+ or +deserialize+.
+user_provided_default+ Whether the default value should be cast using

will be called once each time a new value is needed.
Otherwise, the default will be +nil+. A proc can also be passed, and
is not passed, the previous default value (if any) will be used.
+default+ The default value to use when no value is provided. If this option

+cast_type+ The type object to use for this attribute.

+name+ The name of the attribute being defined. Expected to be a +String+.

should probably use ClassMethods#attribute.
is provided so it can be used by plugin authors, application code
waiting for the schema to load. While this method
This API only accepts type objects, and will do its work immediately instead of
def define_attribute(
  name,
  cast_type,
  default: NO_DEFAULT_PROVIDED,
  user_provided_default: true
)
  attribute_types[name] = cast_type
  define_default_attribute(name, default, cast_type, from_user: user_provided_default)
end

def define_default_attribute(name, value, type, from_user:)

def define_default_attribute(name, value, type, from_user:)
  if value == NO_DEFAULT_PROVIDED
    default_attribute = _default_attributes[name].with_type(type)
  elsif from_user
    default_attribute = ActiveModel::Attribute::UserProvidedDefault.new(
      name,
      value,
      type,
      _default_attributes.fetch(name.to_s) { nil },
    )
  else
    default_attribute = ActiveModel::Attribute.from_database(name, value, type)
  end
  _default_attributes[name] = default_attribute
end

def reload_schema_from_cache(*)

def reload_schema_from_cache(*)
  reset_default_attributes!
  super
end

def reset_default_attributes

def reset_default_attributes
  reload_schema_from_cache
end

def resolve_type_name(name, **options)

def resolve_type_name(name, **options)
  Type.lookup(name, **options, adapter: Type.adapter_name_from(self))
end

def type_for_column(connection, column)

def type_for_column(connection, column)
  hook_attribute_type(column.name, super)
end