Module: ActiveModel::Type

Defined in:
activemodel/lib/active_model/type/registry.rb,
activemodel/lib/active_model/type.rb,
activemodel/lib/active_model/type/date.rb,
activemodel/lib/active_model/type/text.rb,
activemodel/lib/active_model/type/time.rb,
activemodel/lib/active_model/type/float.rb,
activemodel/lib/active_model/type/value.rb,
activemodel/lib/active_model/type/binary.rb,
activemodel/lib/active_model/type/string.rb,
activemodel/lib/active_model/type/boolean.rb,
activemodel/lib/active_model/type/decimal.rb,
activemodel/lib/active_model/type/integer.rb,
activemodel/lib/active_model/type/date_time.rb,
activemodel/lib/active_model/type/big_integer.rb,
activemodel/lib/active_model/type/helpers/mutable.rb,
activemodel/lib/active_model/type/helpers/numeric.rb,
activemodel/lib/active_model/type/immutable_string.rb,
activemodel/lib/active_model/type/unsigned_integer.rb,
activemodel/lib/active_model/type/helpers/time_value.rb,
activemodel/lib/active_model/type/decimal_without_scale.rb,
activemodel/lib/active_model/type/helpers/accepts_multiparameter_time.rb

Overview

:stopdoc:

Defined Under Namespace

Modules: Helpers Classes: BigInteger, Binary, Boolean, Date, DateTime, Decimal, DecimalWithoutScale, Float, ImmutableString, Integer, Registration, Registry, String, Text, Time, UnsignedInteger, Value

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.registryObject

:nodoc:


26
27
28
# File 'activemodel/lib/active_model/type.rb', line 26

def registry
  @registry
end

Class Method Details

.lookup(*args, **kwargs) ⇒ Object

:nodoc:


41
42
43
# File 'activemodel/lib/active_model/type.rb', line 41

def lookup(*args, **kwargs) # :nodoc:
  registry.lookup(*args, **kwargs)
end

.register(type_name, klass = nil, **options, &block) ⇒ Object

Add a new type to the registry, allowing it to be referenced as a symbol by ActiveModel::Attributes::ClassMethods#attribute. If your type is only meant to be used with a specific database adapter, you can do so by passing adapter: :postgresql. If your type has the same name as a native type for the current adapter, an exception will be raised unless you specify an :override option. override: true will cause your type to be used instead of the native type. override: false will cause the native type to be used over yours if one exists.


37
38
39
# File 'activemodel/lib/active_model/type.rb', line 37

def register(type_name, klass = nil, **options, &block)
  registry.register(type_name, klass, **options, &block)
end