Class: ActiveType::TypeCaster::NativeCasters::DelegateToColumn

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

Overview

Adapter for Rails 3.0 - 4.1. In these versions, casting logic lives in ActiveRecord::ConnectionAdapters::Colum

Instance Method Summary collapse

Constructor Details

#initialize(type) ⇒ DelegateToColumn

Returns a new instance of DelegateToColumn.



49
50
51
52
53
54
55
# File 'lib/active_type/type_caster.rb', line 49

def initialize(type)
  # the Column initializer expects type as returned from the database, and
  # resolves them to our types
  # fortunately, for all types wie support, type.to_s is a valid sql_type
  sql_type = type.to_s
  @column = ActiveRecord::ConnectionAdapters::Column.new('foo', nil, sql_type)
end

Instance Method Details

#type_cast_from_user(value) ⇒ Object



57
58
59
# File 'lib/active_type/type_caster.rb', line 57

def type_cast_from_user(value)
  @column.type_cast(value)
end