Skip to content

Commit

Permalink
Simplify Wasabi::Parser#sections implementation using Enumerable#grou…
Browse files Browse the repository at this point in the history
…p_by
  • Loading branch information
bvicenzo authored and olleolleolle committed Aug 4, 2020
1 parent e47045d commit 028044e
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions lib/wasabi/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 028044e

Please sign in to comment.