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::Column

Instance Method Summary collapse

Constructor Details

#initialize(type) ⇒ DelegateToColumn

Returns a new instance of DelegateToColumn.



73
74
75
76
77
78
79
# File 'lib/active_type/type_caster.rb', line 73

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



81
82
83
# File 'lib/active_type/type_caster.rb', line 81

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