Commit 8d8c5d9f authored by Alex Braha Stoll's avatar Alex Braha Stoll

Simplify WikiPage.group_by_directory by using Enumerable#group_by

parent 77fe503a
...@@ -20,15 +20,8 @@ class WikiPage ...@@ -20,15 +20,8 @@ class WikiPage
# arrays. # arrays.
def self.group_by_directory(pages) def self.group_by_directory(pages)
return {} if pages.blank? return {} if pages.blank?
pages = pages.sort_by { |page| [page.directory, page.slug] } pages.sort_by { |page| [page.directory, page.slug] }.
group_by { |page| page.directory }
directories = {}
pages.each do |page|
directories[page.directory] ||= []
directories[page.directory] << page
end
directories
end end
def to_key def to_key
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment