From 028044e73951ac921d467834222ee4d683441167 Mon Sep 17 00:00:00 2001 From: Bruno Vicenzo Date: Tue, 4 Aug 2020 09:37:03 -0300 Subject: [PATCH] Simplify Wasabi::Parser#sections implementation using Enumerable#group_by --- lib/wasabi/parser.rb | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/lib/wasabi/parser.rb b/lib/wasabi/parser.rb index 511080c..7bedb50 100644 --- a/lib/wasabi/parser.rb +++ b/lib/wasabi/parser.rb @@ -319,13 +319,7 @@ def section(section_name) end def sections - @sections ||= begin - sections = {} - document.root.element_children.each do |node| - (sections[node.name] ||= []) << node - end - sections - end + @sections ||= document.root.element_children.group_by { |node| node.name } end end end