module ActiveRecord::Attributes::ClassMethods

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