Class: ActiveRecord::TypeCaster::Map
- Defined in:
- activerecord/lib/active_record/type_caster/map.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize(klass) ⇒ Map
constructor
A new instance of Map.
- #type_cast_for_database(attr_name, value) ⇒ Object
- #type_for_attribute(name) ⇒ Object
Constructor Details
#initialize(klass) ⇒ Map
Returns a new instance of Map.
6 7 8 |
# File 'activerecord/lib/active_record/type_caster/map.rb', line 6 def initialize(klass) @klass = klass end |
Instance Method Details
#type_cast_for_database(attr_name, value) ⇒ Object
10 11 12 13 |
# File 'activerecord/lib/active_record/type_caster/map.rb', line 10 def type_cast_for_database(attr_name, value) type = type_for_attribute(attr_name) type.serialize(value) end |
#type_for_attribute(name) ⇒ Object
15 16 17 |
# File 'activerecord/lib/active_record/type_caster/map.rb', line 15 def type_for_attribute(name) klass.type_for_attribute(name) end |