Use index_with to simplify hash generation

This method was introduced in Rails 6.0. It can be used to take an array
and create a hash where the elements of the array are the indexes of the
hash.
This commit is contained in:
Javi Martín
2022-07-26 02:34:17 +02:00
parent eca1714a26
commit 5b844bf231
4 changed files with 32 additions and 32 deletions

View File

@@ -17,7 +17,7 @@ module Globalize
end
def Globalize.set_fallbacks_to_all_available_locales
Globalize.fallbacks = I18n.available_locales.each_with_object({}) do |locale, fallbacks|
fallbacks[locale] = (I18n.fallbacks[locale] + I18n.available_locales).uniq
Globalize.fallbacks = I18n.available_locales.index_with do |locale|
(I18n.fallbacks[locale] + I18n.available_locales).uniq
end
end