Sha256: f1923a3fcae6e0ed5466670d0b1fbfa30a3cfbb7b34dc60b28ba2bd7e3b0fcc0

Contents?: true

Size: 1.48 KB

Versions: 96

Compression:

Stored size: 1.48 KB

Contents

# frozen_string_literal: true

require "active_model/type/helpers"
require "active_model/type/value"

require "active_model/type/big_integer"
require "active_model/type/binary"
require "active_model/type/boolean"
require "active_model/type/date"
require "active_model/type/date_time"
require "active_model/type/decimal"
require "active_model/type/float"
require "active_model/type/immutable_string"
require "active_model/type/integer"
require "active_model/type/string"
require "active_model/type/time"

require "active_model/type/registry"

module ActiveModel
  module Type
    @registry = Registry.new

    class << self
      attr_accessor :registry # :nodoc:

      # Add a new type to the registry, allowing it to be gotten through ActiveModel::Type#lookup
      def register(type_name, klass = nil, **options, &block)
        registry.register(type_name, klass, **options, &block)
      end

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

      def default_value # :nodoc:
        @default_value ||= Value.new
      end
    end

    register(:big_integer, Type::BigInteger)
    register(:binary, Type::Binary)
    register(:boolean, Type::Boolean)
    register(:date, Type::Date)
    register(:datetime, Type::DateTime)
    register(:decimal, Type::Decimal)
    register(:float, Type::Float)
    register(:immutable_string, Type::ImmutableString)
    register(:integer, Type::Integer)
    register(:string, Type::String)
    register(:time, Type::Time)
  end
end

Version data entries

96 entries across 96 versions & 10 rubygems

Version Path
activemodel-6.0.0.rc1 lib/active_model/type.rb
activemodel-5.2.3 lib/active_model/type.rb
activemodel-5.2.3.rc1 lib/active_model/type.rb
activemodel-6.0.0.beta3 lib/active_model/type.rb
activemodel-5.2.2.1 lib/active_model/type.rb
activemodel-6.0.0.beta2 lib/active_model/type.rb
activemodel-6.0.0.beta1 lib/active_model/type.rb
nullifyable-0.1.0 vendor/bundle/gems/activemodel-5.2.2/lib/active_model/type.rb
activemodel-5.2.2 lib/active_model/type.rb
activemodel-5.2.2.rc1 lib/active_model/type.rb
activemodel-5.2.1.1 lib/active_model/type.rb
activemodel-5.2.1 lib/active_model/type.rb
activemodel-5.2.1.rc1 lib/active_model/type.rb
activemodel-5.2.0 lib/active_model/type.rb
activemodel-5.2.0.rc2 lib/active_model/type.rb
activemodel-5.2.0.rc1 lib/active_model/type.rb