diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-06-26 12:54:22 -0300 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-06-26 22:05:56 -0300 |
commit | 60571b853920707c1103c5f9659e7b690d8eae73 (patch) | |
tree | d2054a5a54c058a0217ad569076832382c9fe8a7 /activesupport/lib/active_support/core_ext/array/conversions.rb | |
parent | 5847f59b2506d40e45edc2db671b897b9bffe640 (diff) | |
download | rails-60571b853920707c1103c5f9659e7b690d8eae73.tar.gz rails-60571b853920707c1103c5f9659e7b690d8eae73.tar.bz2 rails-60571b853920707c1103c5f9659e7b690d8eae73.zip |
Ensure Array#to_sentence does not modify given hash
Also simplify I18n logic for Array#to_sentence, doing only one lookup
for all keys and using merge!, instead of one lookup for each option key.
Diffstat (limited to 'activesupport/lib/active_support/core_ext/array/conversions.rb')
-rw-r--r-- | activesupport/lib/active_support/core_ext/array/conversions.rb | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/activesupport/lib/active_support/core_ext/array/conversions.rb b/activesupport/lib/active_support/core_ext/array/conversions.rb index 1e0de651c7..d6ae031c0d 100644 --- a/activesupport/lib/active_support/core_ext/array/conversions.rb +++ b/activesupport/lib/active_support/core_ext/array/conversions.rb @@ -1,6 +1,5 @@ require 'active_support/xml_mini' require 'active_support/core_ext/hash/keys' -require 'active_support/core_ext/hash/reverse_merge' require 'active_support/core_ext/string/inflections' class Array @@ -62,14 +61,10 @@ class Array :last_word_connector => ', and ' } if defined?(I18n) - namespace = 'support.array.' - default_connectors.each_key do |name| - i18n_key = (namespace + name.to_s).to_sym - default_connectors[name] = I18n.translate i18n_key, :locale => options[:locale] - end + i18n_connectors = I18n.translate(:'support.array', locale: options[:locale], default: {}) + default_connectors.merge!(i18n_connectors) end - - options.reverse_merge! default_connectors + options = default_connectors.merge!(options) case length when 0 |