aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/type/numeric.rb
blob: a3379831cb0b1a66d73bee5123ce831dac9c2fc3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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