From 4af5e1d46de40924ff734448884d34f3633ec946 Mon Sep 17 00:00:00 2001 From: Angel Perez Date: Mon, 20 Aug 2018 10:43:57 -0400 Subject: [PATCH] Improve I18nContent#flat_hash readability using concise variable names --- app/models/i18n_content.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/i18n_content.rb b/app/models/i18n_content.rb index c018cf4dc..bc7544f6a 100644 --- a/app/models/i18n_content.rb +++ b/app/models/i18n_content.rb @@ -40,10 +40,10 @@ class I18nContent < ActiveRecord::Base # 'string.key2.key4.key5' => 'value3' # } - def self.flat_hash(h, f = nil, g = {}) - return g.update({ f => h }) unless h.is_a? Hash - h.map { |k, r| flat_hash(r, [f, k].compact.join('.'), g) } - return g + def self.flat_hash(input, path = nil, output = {}) + return output.update({ path => input }) unless input.is_a? Hash + input.map { |key, value| flat_hash(value, [path, key].compact.join('.'), output) } + return output end end