Refactoring: Prefer each_with_object over tap.

This commit is contained in:
Thorsten Eckel 2017-10-18 11:14:26 +02:00
parent c710389c80
commit ef17e67b60

View file

@ -204,11 +204,9 @@ module HasGroups
return {} if !active? return {} if !active?
return {} if !groups_access_permission? return {} if !groups_access_permission?
{}.tap do |hash| groups.access.where(active: true).pluck(key, :access).each_with_object({}) do |entry, hash|
groups.access.where(active: true).pluck(key, :access).each do |entry| hash[ entry[0] ] ||= []
hash[ entry[0] ] ||= [] hash[ entry[0] ].push(entry[1])
hash[ entry[0] ].push(entry[1])
end
end end
end end