class method self.value_to_decimal

Ruby on Rails 2.3.18

Since v2.2.3 Last seen in v3.0.20

Available in: v2.2.3 v2.3.18 v3.0.20

Signature

self.value_to_decimal(value)

convert something to a BigDecimal

Parameters

value req
Source
# File activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb, line 156
        def value_to_decimal(value)
          # Using .class is faster than .is_a? and
          # subclasses of BigDecimal will be handled
          # in the else clause
          if value.class == BigDecimal
            value
          elsif value.respond_to?(:to_d)
            value.to_d
          else
            value.to_s.to_d
          end
        end

Defined in activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb line 156 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::ConnectionAdapters::Column

Type at least 2 characters to search.

↑↓ navigate · open · esc close