- 模块 ActiveRecord::Type::Internal
- 类 ActiveRecord::Type::BigInteger
- 类 ActiveRecord::Type::Binary
- 类 ActiveRecord::Type::Boolean
- 类 ActiveRecord::Type::Date
- 类 ActiveRecord::Type::DateTime
- 类 ActiveRecord::Type::Decimal
- 类 ActiveRecord::Type::Float
- 类 ActiveRecord::Type::ImmutableString
- 类 ActiveRecord::Type::Integer
- 类 ActiveRecord::Type::Json
- 类 ActiveRecord::Type::String
- 类 ActiveRecord::Type::Time
- 类 ActiveRecord::Type::Value
- R
常量
BigInteger | = | ActiveModel::Type::BigInteger |
Active Model BigInteger 类型用于可以序列化为无限字节数的整数的属性类型。此类型在
所有转换和序列化都以与标准 |
||
Binary | = | ActiveModel::Type::Binary |
Active Model 二进制类型用于表示二进制数据的属性类型。此类型在 非字符串值将使用其 `to_s` 方法强制转换为字符串。 |
||
布尔值 | = | ActiveModel::Type::Boolean |
Active Model 布尔值类型一个表现得像布尔值类型的类,包括用户输入强制转换规则。
|
||
十进制 | = | ActiveModel::Type::Decimal |
Active Model 十进制类型十进制属性类型,高精度浮点数值表示。它在 `:decimal` 键下注册。
|
||
浮点数 | = | ActiveModel::Type::Float |
Active Model 浮点数类型浮点数值属性类型。它在 `:float` 键下注册。
值将使用其 `to_f` 方法进行强制转换,但以下字符串除外
|
||
不可变字符串 | = | ActiveModel::Type::ImmutableString |
Active Model 不可变字符串类型属性类型,用于表示不可变字符串。它将传入的值强制转换为冻结字符串。
值将使用其 `to_s` 方法强制转换为字符串。但是,
|
||
整数 | = | ActiveModel::Type::Integer |
Active Model 整数类型用于表示整数的属性类型。此类型在
值使用其
|
||
字符串 | = | ActiveModel::Type::String |
Active Model 字符串类型用于字符串的属性类型。它在 此类是 |
||
值 | = | ActiveModel::Type::Value |
Active Model 值类型所有属性类型的基类。此类还用作未指定类型的属性的默认类型。 |
类公共方法
register(type_name, klass = nil, **options, &block) 链接
向注册表添加一个新类型,允许它被 ActiveRecord::Base.attribute 作为符号引用。如果您的类型仅用于特定数据库适配器,则可以通过传递 adapter: :postgresql
来实现。如果您的类型与当前适配器的本机类型具有相同的名称,则除非您指定 :override
选项,否则将引发异常。override: true
将导致使用您的类型而不是本机类型。override: false
将导致如果存在本机类型,则使用本机类型而不是您的类型。
来源:显示 | 在 GitHub 上
# File activerecord/lib/active_record/type.rb, line 37 def register(type_name, klass = nil, **options, &block) registry.register(type_name, klass, **options, &block) end