aboutsummaryrefslogblamecommitdiffstats
path: root/activerecord/lib/active_record/type_caster/map.rb
blob: 52529a6b42fbaa6652536f06b01ad73645dce302 (plain) (tree)
1
2
3
4
5
6
7
8
9
10

                   
                       






                                                           
                             



               
                          


       
module ActiveRecord
  module TypeCaster
    class Map # :nodoc:
      def initialize(types)
        @types = types
      end

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

      protected

        attr_reader :types
    end
  end
end