Sha256: cf9078729d87f2d8fce1d74f96557cae56c66aff79764525b5c230be5770f6b3

Contents?: true

Size: 557 Bytes

Versions: 31

Compression:

Stored size: 557 Bytes

Contents

# frozen_string_literal: true

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)
        type.serialize(value)
      end

      # TODO Change this to private once we've dropped Ruby 2.2 support.
      # Workaround for Ruby 2.2 "private attribute?" warning.
      protected

        attr_reader :types
    end
  end
end

Version data entries

31 entries across 31 versions & 3 rubygems

Version Path
activerecord-5.2.8.1 lib/active_record/type_caster/map.rb
activerecord-5.2.8 lib/active_record/type_caster/map.rb
activerecord-5.2.7.1 lib/active_record/type_caster/map.rb
activerecord-5.2.7 lib/active_record/type_caster/map.rb
activerecord-5.2.6.3 lib/active_record/type_caster/map.rb
activerecord-5.2.6.2 lib/active_record/type_caster/map.rb
activerecord-5.2.6.1 lib/active_record/type_caster/map.rb
activerecord-5.2.6 lib/active_record/type_caster/map.rb
activerecord-5.2.4.6 lib/active_record/type_caster/map.rb
activerecord-5.2.5 lib/active_record/type_caster/map.rb
activerecord-5.2.4.5 lib/active_record/type_caster/map.rb
activerecord-5.2.4.4 lib/active_record/type_caster/map.rb
activerecord-5.2.4.3 lib/active_record/type_caster/map.rb
activerecord-5.2.4.2 lib/active_record/type_caster/map.rb
activerecord-5.2.4.1 lib/active_record/type_caster/map.rb
activerecord-5.2.4 lib/active_record/type_caster/map.rb
activerecord-5.2.4.rc1 lib/active_record/type_caster/map.rb
spiral_form-0.1.1 vendor/bundle/gems/activerecord-5.2.3/lib/active_record/type_caster/map.rb
spiral_form-0.1.0 vendor/bundle/gems/activerecord-5.2.3/lib/active_record/type_caster/map.rb
activerecord-5.2.3 lib/active_record/type_caster/map.rb