[Why] 1. We had for-each key-value in hash, needn't query value by key once more. 2. When remove empty value of Hash(String, Hash(String, Array(...)), remove the first level key-value at first.
Signed-off-by: Lu Weitao luweitaobe@163.com --- lib/params_group.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/lib/params_group.rb b/lib/params_group.rb index 7bb7f5b..fa71653 100644 --- a/lib/params_group.rb +++ b/lib/params_group.rb @@ -72,10 +72,13 @@ end
def filter_groups(groups) groups.each do |group_key, value| - value.each_key do |dim_key| - value.delete(dim_key) if value[dim_key].empty? + if value.empty? + groups.delete(group_key) + next + end + value.each do |dim_key, job_list| + value.delete(dim_key) if job_list.empty? end - groups.delete(group_key) if groups[group_key].empty? end end