Sha256: 799cb20151f488d12549dd4d69d00c8b85a9e5541eef530b4de6f29e7c72c0c2

Contents?: true

Size: 732 Bytes

Versions: 35

Compression:

Stored size: 732 Bytes

Contents

module ActiveRecord
  module TypeCaster
    class Connection # :nodoc:
      def initialize(klass, table_name)
        @klass = klass
        @table_name = table_name
      end

      def type_cast_for_database(attribute_name, value)
        return value if value.is_a?(Arel::Nodes::BindParam)
        column = column_for(attribute_name)
        connection.type_cast_from_column(column, value)
      end

      protected

      attr_reader :table_name
      delegate :connection, to: :@klass

      private

      def column_for(attribute_name)
        if connection.schema_cache.data_source_exists?(table_name)
          connection.schema_cache.columns_hash(table_name)[attribute_name.to_s]
        end
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 4 rubygems

Version Path
activerecord-5.0.7.2 lib/active_record/type_caster/connection.rb
activerecord-5.0.7.1 lib/active_record/type_caster/connection.rb
activerecord-5.0.7 lib/active_record/type_caster/connection.rb
activerecord-5.0.6 lib/active_record/type_caster/connection.rb
activerecord-5.0.6.rc1 lib/active_record/type_caster/connection.rb
activerecord-5.0.5 lib/active_record/type_caster/connection.rb
activerecord-5.0.5.rc2 lib/active_record/type_caster/connection.rb
activerecord-5.0.5.rc1 lib/active_record/type_caster/connection.rb
activerecord-5.0.4 lib/active_record/type_caster/connection.rb
activerecord-5.0.4.rc1 lib/active_record/type_caster/connection.rb
activerecord-5.0.3 lib/active_record/type_caster/connection.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/activerecord-5.0.2/lib/active_record/type_caster/connection.rb
activerecord-5.0.2 lib/active_record/type_caster/connection.rb
activerecord-5.0.2.rc1 lib/active_record/type_caster/connection.rb
autocompl-0.2.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.1/lib/active_record/type_caster/connection.rb
autocompl-0.2.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.1/lib/active_record/type_caster/connection.rb
autocompl-0.2.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.1/lib/active_record/type_caster/connection.rb
autocompl-0.1.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.1/lib/active_record/type_caster/connection.rb
autocompl-0.1.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.1/lib/active_record/type_caster/connection.rb
autocompl-0.1.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.1/lib/active_record/type_caster/connection.rb