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