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


                           
                           

                       


                  
 



                      


                             




                                     
           



         
module ActiveRecord
  module ConnectionAdapters
    module Type
      class Decimal < Value
        include Numeric

        def type
          :decimal
        end

        def klass
          ::BigDecimal
        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