aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2016-01-29 01:53:21 -0500
committerRafael França <rafaelmfranca@gmail.com>2016-01-29 01:53:21 -0500
commit22261405a38dbab84c98925fb4cfbef700d400a4 (patch)
tree496d345a52e8cbaeb0d149f3b18743ffe85b1b3a /activesupport/lib
parent4de092240004e31c512810b19e1b7a83e1ddc77e (diff)
parentd3f178bb92473b4d7bb400be56c983203b1662e9 (diff)
downloadrails-22261405a38dbab84c98925fb4cfbef700d400a4.tar.gz
rails-22261405a38dbab84c98925fb4cfbef700d400a4.tar.bz2
rails-22261405a38dbab84c98925fb4cfbef700d400a4.zip
Merge pull request #23329 from prathamesh-sonpatki/fix-23320
Change number_to_currency behavior for checking negativity of a number
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/number_helper/number_to_currency_converter.rb6
1 files changed, 1 insertions, 5 deletions
diff --git a/activesupport/lib/active_support/number_helper/number_to_currency_converter.rb b/activesupport/lib/active_support/number_helper/number_to_currency_converter.rb
index 7986eb50f0..fe8e871fed 100644
--- a/activesupport/lib/active_support/number_helper/number_to_currency_converter.rb
+++ b/activesupport/lib/active_support/number_helper/number_to_currency_converter.rb
@@ -7,7 +7,7 @@ module ActiveSupport
number = self.number.to_s.strip
format = options[:format]
- if is_negative?(number)
+ if number.to_f.negative?
format = options[:negative_format]
number = absolute_value(number)
end
@@ -18,10 +18,6 @@ module ActiveSupport
private
- def is_negative?(number)
- number.to_f.phase != 0
- end
-
def absolute_value(number)
number.respond_to?(:abs) ? number.abs : number.sub(/\A-/, '')
end