Class: ActiveType::TypeCaster::NativeCasters::DelegateToRails4Type

Inherits:
Object
  • Object
show all
Defined in:
lib/active_type/type_caster.rb

Overview

Adapter for Rails 4.2+. In these versions, casting logic lives in subclasses of ActiveRecord::Type::Value

Instance Method Summary collapse

Constructor Details

#initialize(type) ⇒ DelegateToRails4Type

Returns a new instance of DelegateToRails4Type.



91
92
93
94
95
96
97
# File 'lib/active_type/type_caster.rb', line 91

def initialize(type)
  # The specified type (e.g. "string") may not necessary match the
  # native type ("varchar") expected by the connection adapter.
  # PostgreSQL is one of these. Perform a translation if the adapter
  # supports it (but don't turn a mysql boolean into a tinyint).
  @active_record_type = ActiveRecord::ConnectionAdapters::AbstractAdapter.new(nil).lookup_cast_type(type)
end

Instance Method Details

#type_cast_from_user(value) ⇒ Object



99
100
101
# File 'lib/active_type/type_caster.rb', line 99

def type_cast_from_user(value)
  @active_record_type.type_cast_from_user(value)
end