Class: ActiveRecord::TypeCaster::Connection

Inherits:
Object
  • Object
show all
Defined in:
activerecord/lib/active_record/type_caster/connection.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(klass, table_name) ⇒ Connection


4
5
6
7
# File 'activerecord/lib/active_record/type_caster/connection.rb', line 4

def initialize(klass, table_name)
  @klass = klass
  @table_name = table_name
end

Instance Method Details

#type_cast_for_database(attribute_name, value) ⇒ Object


9
10
11
12
13
# File 'activerecord/lib/active_record/type_caster/connection.rb', line 9

def type_cast_for_database(attribute_name, value)
  return value if value.is_a?(Arel::Nodes::BindParam)
  column = column_for(attribute_name)
  connection.type_cast_from_column(column, value)
end