aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/type/decimal.rb
blob: 3a9c470dbafdd11d904a8f0a0a03735dd5af41e8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
module ActiveRecord
  module ConnectionAdapters
    module Type
      class Decimal < Value # :nodoc:
        def type
          :decimal
        end

        private

        def cast_value(value)
          if value.respond_to?(:to_d)
            value.to_d
          else
            value.to_s.to_d
          end
        end
      end
    end
  end
end