Class: ActiveRecord::TypeCaster::Map

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

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(types) ⇒ Map

Returns a new instance of Map.



6
7
8
# File 'activerecord/lib/active_record/type_caster/map.rb', line 6

def initialize(types)
  @types = types
end

Instance Method Details

#type_cast_for_database(attr_name, value) ⇒ Object



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

def type_cast_for_database(attr_name, value)
  return value if value.is_a?(Arel::Nodes::BindParam)
  type = types.type_for_attribute(attr_name)
  type.serialize(value)
end