Skip to content

Commit 400c5fe

Browse files
Review requires from number helper
Some of these requires are now only necessary in ActiveSupport::NumberHelper. Add hash/keys require due to symbolize_keys usage in number helpers. Also remove some whitespaces. Closes rails#6414
1 parent f9cb645 commit 400c5fe

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

actionpack/lib/action_view/helpers/number_helper.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
# encoding: utf-8
22

3-
require 'active_support/core_ext/big_decimal/conversions'
4-
require 'active_support/core_ext/object/blank'
5-
require 'active_support/core_ext/numeric'
3+
require 'active_support/core_ext/hash/keys'
64
require 'active_support/core_ext/string/output_safety'
75
require 'active_support/number_helper'
86

97
module ActionView
108
# = Action View Number Helpers
119
module Helpers #:nodoc:
1210

13-
1411
# Provides methods for converting numbers into formatted strings.
1512
# Methods are provided for phone numbers, currency, percentage,
1613
# precision, positional notation, file size and pretty printing.

activesupport/lib/active_support/core_ext/numeric/conversions.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
require 'active_support/number_helper'
33

44
class Numeric
5-
5+
66
# Provides options for converting numbers into formatted strings.
77
# Options are provided for phone numbers, currency, percentage,
88
# precision, positional notation, file size and pretty printing.
@@ -97,7 +97,7 @@ class Numeric
9797
# 1234567.to_s(:human, :precision => 1,
9898
# :separator => ',',
9999
# :significant => false) # => "1,2 Million"
100-
def to_formatted_s(format = :default, options = {})
100+
def to_formatted_s(format = :default, options = {})
101101
case format
102102
when :phone
103103
return ActiveSupport::NumberHelper.number_to_phone(self, options)
@@ -117,19 +117,19 @@ def to_formatted_s(format = :default, options = {})
117117
self.to_default_s
118118
end
119119
end
120-
120+
121121
[Float, Fixnum, Bignum, BigDecimal].each do |klass|
122122
klass.send(:alias_method, :to_default_s, :to_s)
123-
123+
124124
klass.send(:define_method, :to_s) do |*args|
125125
if args[0].is_a?(Symbol)
126126
format = args[0]
127127
options = args[1] || {}
128-
128+
129129
self.to_formatted_s(format, options)
130130
else
131131
to_default_s(*args)
132132
end
133133
end
134134
end
135-
end
135+
end

activesupport/lib/active_support/number_helper.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -498,14 +498,13 @@ def number_to_human(number, options = {})
498498
formatted_number = self.number_to_rounded(number, options)
499499
decimal_format.gsub(/%n/, formatted_number).gsub(/%u/, unit).strip
500500
end
501-
502-
501+
503502
def self.private_module_and_instance_method(method_name)
504503
private method_name
505504
private_class_method method_name
506505
end
507506
private_class_method :private_module_and_instance_method
508-
507+
509508
def format_translations(namespace, locale)
510509
defaults_translations(locale).merge(translations_for(namespace, locale))
511510
end
@@ -527,6 +526,6 @@ def valid_float?(number)
527526
false
528527
end
529528
private_module_and_instance_method :valid_float?
530-
529+
531530
end
532-
end
531+
end

0 commit comments

Comments
 (0)