From d0fbabeb0b5e835ee846e99e06c8b1ac6fcf353f Mon Sep 17 00:00:00 2001 From: Oren Dobzinski Date: Tue, 18 Feb 2014 23:36:07 -0500 Subject: [PATCH] simplify TopicPostersSummary --- app/models/topic_posters_summary.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/models/topic_posters_summary.rb b/app/models/topic_posters_summary.rb index d3e6613c38d..8ab031fd2df 100644 --- a/app/models/topic_posters_summary.rb +++ b/app/models/topic_posters_summary.rb @@ -7,7 +7,7 @@ class TopicPostersSummary end def summary - sorted_top_posters.map { |user| user ? new_topic_poster_for(user) : nil }.compact + sorted_top_posters.compact.map(&method(:new_topic_poster_for)) end private @@ -22,10 +22,9 @@ class TopicPostersSummary def descriptions_by_id @descriptions_by_id ||= begin - user_ids_with_descriptions.inject({}) do |descriptions, (id, description)| + user_ids_with_descriptions.each_with_object({}) do |(id, description), descriptions| descriptions[id] ||= [] descriptions[id] << description - descriptions end end end