Class: ActiveRecord::TypeCaster::Connection
    Do not use.  This class is for internal use only.
  
| Relationships & Source Files | |
| Inherits: | Object | 
| Defined in: | activerecord/lib/active_record/type_caster/connection.rb | 
Class Method Summary
- .new(klass, table_name) ⇒ Connection constructor
 
Instance Attribute Summary
- #table_name readonly private
 
Instance Method Summary
Constructor Details
    .new(klass, table_name)  ⇒ Connection 
  
# File 'activerecord/lib/active_record/type_caster/connection.rb', line 6
def initialize(klass, table_name) @klass = klass @table_name = table_name end
Instance Attribute Details
#table_name (readonly, private)
[ GitHub ]# File 'activerecord/lib/active_record/type_caster/connection.rb', line 31
attr_reader :table_name
Instance Method Details
#type_cast_for_database(attr_name, value)
[ GitHub ]# File 'activerecord/lib/active_record/type_caster/connection.rb', line 11
def type_cast_for_database(attr_name, value) type = type_for_attribute(attr_name) type.serialize(value) end
#type_for_attribute(attr_name)
[ GitHub ]# File 'activerecord/lib/active_record/type_caster/connection.rb', line 16
def type_for_attribute(attr_name) schema_cache = @klass.schema_cache if schema_cache.data_source_exists?(table_name) column = schema_cache.columns_hash(table_name)[attr_name.to_s] if column # TODO: Remove fetch_cast_type and the need for connection after we release 8.1. type = column.fetch_cast_type(@klass.lease_connection) end end type || Type.default_value end