Skip to content

Commit 0a3fc7e

Browse files
author
Andreas Brandl
committed
Use yield instead of block.call.
1 parent 82a32e2 commit 0a3fc7e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

app/finders/snippets_finder.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,25 +61,25 @@ def authorized_snippets
6161
# Returns a collection of projects that is either public or visible to the
6262
# logged in user.
6363
#
64-
# A caller may pass in a block to modify individual parts of
64+
# A caller must pass in a block to modify individual parts of
6565
# the query, e.g. to apply .with_feature_available_for_user on top of it.
6666
# This is useful for performance as we can stick those additional filters
6767
# at the bottom of e.g. the UNION.
68-
def projects_for_user(&block)
69-
return block.call(Project.public_to_user) unless current_user
68+
def projects_for_user
69+
return yield(Project.public_to_user) unless current_user
7070

7171
# If the current_user is allowed to see all projects,
7272
# we can shortcut and just return.
73-
return block.call(Project.all) if current_user.full_private_access?
73+
return yield(Project.all) if current_user.full_private_access?
7474

7575
authorized = current_user
7676
.project_authorizations
7777
.select(1)
7878
.where('project_authorizations.project_id = projects.id')
79-
authorized_projects = block.call(Project.where('EXISTS (?)', authorized))
79+
authorized_projects = yield(Project.where('EXISTS (?)', authorized))
8080

8181
levels = Gitlab::VisibilityLevel.levels_for_user(current_user)
82-
visible_projects = block.call(Project.where(visibility_level: levels))
82+
visible_projects = yield(Project.where(visibility_level: levels))
8383

8484
# We use a UNION here instead of OR clauses since this results in better
8585
# performance.

0 commit comments

Comments
 (0)