diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-03-16 09:22:09 -0600 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-03-16 16:33:15 -0600 |
commit | 871bed7ac0a777d6187cbf09362c5fae441a8607 (patch) | |
tree | a0b8aa6a3dc1f487e566a062ae4ddc3f3eaf1be3 /app | |
parent | 0928d3cd82682e38c54729078afee315b000625d (diff) | |
download | gitlab-ce-871bed7ac0a777d6187cbf09362c5fae441a8607.tar.gz |
Use Enumerable#index_by where possibledm-use-index-by
Diffstat (limited to 'app')
-rw-r--r-- | app/services/merge_requests/get_urls_service.rb | 5 | ||||
-rw-r--r-- | app/services/users/refresh_authorized_projects_service.rb | 4 |
2 files changed, 2 insertions, 7 deletions
diff --git a/app/services/merge_requests/get_urls_service.rb b/app/services/merge_requests/get_urls_service.rb index 1262ecbc29a..ae386b53f42 100644 --- a/app/services/merge_requests/get_urls_service.rb +++ b/app/services/merge_requests/get_urls_service.rb @@ -23,10 +23,7 @@ module MergeRequests def opened_merge_requests_from_source_branches(branches) merge_requests = MergeRequest.from_project(project).opened.from_source_branches(branches) - merge_requests.inject({}) do |hash, mr| - hash[mr.source_branch] = mr - hash - end + merge_requests.index_by(&:source_branch) end def get_branches(changes) diff --git a/app/services/users/refresh_authorized_projects_service.rb b/app/services/users/refresh_authorized_projects_service.rb index d9370bbb598..8f6f5b937c4 100644 --- a/app/services/users/refresh_authorized_projects_service.rb +++ b/app/services/users/refresh_authorized_projects_service.rb @@ -93,9 +93,7 @@ module Users end def current_authorizations_per_project - current_authorizations.each_with_object({}) do |row, hash| - hash[row.project_id] = row - end + current_authorizations.index_by(&:project_id) end def current_authorizations |