Optimisation for BigDecimal conversion code. Closes #11110 [adymo]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8870 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
039f724c7b
commit
838b02450a
@ -4,6 +4,8 @@
|
||||
|
||||
* Improve associations performance by avoiding named block arguments. #11109 [adymo]
|
||||
|
||||
* Optimise the BigDecimal conversion code. #11110 [adymo]
|
||||
|
||||
* Introduce the :readonly option to all associations. Records from the association cannot be saved. #11084 [miloops]
|
||||
|
||||
* Multiparameter attributes for time columns fail over to DateTime when out of range of Time [Geoff Buesing]
|
||||
|
@ -144,7 +144,10 @@ def value_to_boolean(value)
|
||||
|
||||
# convert something to a BigDecimal
|
||||
def value_to_decimal(value)
|
||||
if value.is_a?(BigDecimal)
|
||||
# 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
|
||||
|
Loading…
Reference in New Issue
Block a user