aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/big_decimal/conversions.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-11-29 05:07:40 -0200
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-11-29 05:07:40 -0200
commit4eb68d8ed47c383f717efc8ad757949596a8b99c (patch)
treede5c551da6cee48a3522160594de15fa90f9209e /activesupport/lib/active_support/core_ext/big_decimal/conversions.rb
parent86857868f8bdb33a865d9483c53cd0a5583bb7cc (diff)
parente3cba67824499804065f385b9e6cc1f73596f5ee (diff)
downloadrails-4eb68d8ed47c383f717efc8ad757949596a8b99c.tar.gz
rails-4eb68d8ed47c383f717efc8ad757949596a8b99c.tar.bz2
rails-4eb68d8ed47c383f717efc8ad757949596a8b99c.zip
Merge pull request #17816 from byroot/prevent-numeric-to-s-to-allocate-an-array
Prevent Numeric#to_s from allocating an array
Diffstat (limited to 'activesupport/lib/active_support/core_ext/big_decimal/conversions.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/big_decimal/conversions.rb13
1 files changed, 6 insertions, 7 deletions
diff --git a/activesupport/lib/active_support/core_ext/big_decimal/conversions.rb b/activesupport/lib/active_support/core_ext/big_decimal/conversions.rb
index 843c592669..234283e792 100644
--- a/activesupport/lib/active_support/core_ext/big_decimal/conversions.rb
+++ b/activesupport/lib/active_support/core_ext/big_decimal/conversions.rb
@@ -3,14 +3,13 @@ require 'bigdecimal/util'
class BigDecimal
DEFAULT_STRING_FORMAT = 'F'
- def to_formatted_s(*args)
- if args[0].is_a?(Symbol)
- super
+ alias_method :to_default_s, :to_s
+
+ def to_s(format = nil, options = nil)
+ if format.is_a?(Symbol)
+ to_formatted_s(format, options || {})
else
- format = args[0] || DEFAULT_STRING_FORMAT
- _original_to_s(format)
+ to_default_s(format || DEFAULT_STRING_FORMAT)
end
end
- alias_method :_original_to_s, :to_s
- alias_method :to_s, :to_formatted_s
end