aboutsummaryrefslogblamecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/type/numeric.rb
blob: a3379831cb0b1a66d73bee5123ce831dac9c2fc3 (plain) (tree)
1
2
3
4
5
6
7






                              








                                           



         
module ActiveRecord
  module ConnectionAdapters
    module Type
      module Numeric # :nodoc:
        def number?
          true
        end

        def type_cast_for_write(value)
          case value
          when true then 1
          when false then 0
          when ::String then value.presence
          else super
          end
        end
      end
    end
  end
end