class method
self.value_to_decimal
Ruby on Rails 3.0.20
Since v2.2.3 Last seen in v3.0.20Signature
self.value_to_decimal(value)
convert something to a BigDecimal
Parameters
-
valuereq
Source
# File activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb, line 159
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 159
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::ConnectionAdapters::Column