From ef17e67b6091c59d144b3e455462dc922ba0bd91 Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Wed, 18 Oct 2017 11:14:26 +0200 Subject: [PATCH] Refactoring: Prefer each_with_object over tap. --- app/models/concerns/has_groups.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/models/concerns/has_groups.rb b/app/models/concerns/has_groups.rb index 4b5788b19..8191049d5 100644 --- a/app/models/concerns/has_groups.rb +++ b/app/models/concerns/has_groups.rb @@ -204,11 +204,9 @@ module HasGroups return {} if !active? return {} if !groups_access_permission? - {}.tap do |hash| - groups.access.where(active: true).pluck(key, :access).each do |entry| - hash[ entry[0] ] ||= [] - hash[ entry[0] ].push(entry[1]) - end + groups.access.where(active: true).pluck(key, :access).each_with_object({}) do |entry, hash| + hash[ entry[0] ] ||= [] + hash[ entry[0] ].push(entry[1]) end end