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 #6414
This commit is contained in:
parent
f9cb645dfc
commit
400c5fefcf
@ -1,8 +1,6 @@
|
||||
# encoding: utf-8
|
||||
|
||||
require 'active_support/core_ext/big_decimal/conversions'
|
||||
require 'active_support/core_ext/object/blank'
|
||||
require 'active_support/core_ext/numeric'
|
||||
require 'active_support/core_ext/hash/keys'
|
||||
require 'active_support/core_ext/string/output_safety'
|
||||
require 'active_support/number_helper'
|
||||
|
||||
@ -10,7 +8,6 @@ module ActionView
|
||||
# = Action View Number Helpers
|
||||
module Helpers #:nodoc:
|
||||
|
||||
|
||||
# Provides methods for converting numbers into formatted strings.
|
||||
# Methods are provided for phone numbers, currency, percentage,
|
||||
# precision, positional notation, file size and pretty printing.
|
||||
|
@ -2,7 +2,7 @@
|
||||
require 'active_support/number_helper'
|
||||
|
||||
class Numeric
|
||||
|
||||
|
||||
# Provides options for converting numbers into formatted strings.
|
||||
# Options are provided for phone numbers, currency, percentage,
|
||||
# precision, positional notation, file size and pretty printing.
|
||||
@ -97,7 +97,7 @@ class Numeric
|
||||
# 1234567.to_s(:human, :precision => 1,
|
||||
# :separator => ',',
|
||||
# :significant => false) # => "1,2 Million"
|
||||
def to_formatted_s(format = :default, options = {})
|
||||
def to_formatted_s(format = :default, options = {})
|
||||
case format
|
||||
when :phone
|
||||
return ActiveSupport::NumberHelper.number_to_phone(self, options)
|
||||
@ -117,19 +117,19 @@ def to_formatted_s(format = :default, options = {})
|
||||
self.to_default_s
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
[Float, Fixnum, Bignum, BigDecimal].each do |klass|
|
||||
klass.send(:alias_method, :to_default_s, :to_s)
|
||||
|
||||
|
||||
klass.send(:define_method, :to_s) do |*args|
|
||||
if args[0].is_a?(Symbol)
|
||||
format = args[0]
|
||||
options = args[1] || {}
|
||||
|
||||
|
||||
self.to_formatted_s(format, options)
|
||||
else
|
||||
to_default_s(*args)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -498,14 +498,13 @@ def number_to_human(number, options = {})
|
||||
formatted_number = self.number_to_rounded(number, options)
|
||||
decimal_format.gsub(/%n/, formatted_number).gsub(/%u/, unit).strip
|
||||
end
|
||||
|
||||
|
||||
|
||||
def self.private_module_and_instance_method(method_name)
|
||||
private method_name
|
||||
private_class_method method_name
|
||||
end
|
||||
private_class_method :private_module_and_instance_method
|
||||
|
||||
|
||||
def format_translations(namespace, locale)
|
||||
defaults_translations(locale).merge(translations_for(namespace, locale))
|
||||
end
|
||||
@ -527,6 +526,6 @@ def valid_float?(number)
|
||||
false
|
||||
end
|
||||
private_module_and_instance_method :valid_float?
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user