summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Brandl <abrandl@gitlab.com>2018-03-02 10:15:52 +0100
committerAndreas Brandl <abrandl@gitlab.com>2018-03-02 10:15:52 +0100
commit0a3fc7e3c283c10ef8415a719e83e80f0122af7d (patch)
tree5078f700bead833af41fafb3cfe48c9d126c542b
parent82a32e2763db3196421412a537e9fd344b12c831 (diff)
downloadgitlab-ce-0a3fc7e3c283c10ef8415a719e83e80f0122af7d.tar.gz
Use yield instead of block.call.
-rw-r--r--app/finders/snippets_finder.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/app/finders/snippets_finder.rb b/app/finders/snippets_finder.rb
index fc257933e57..565955ffc05 100644
--- a/app/finders/snippets_finder.rb
+++ b/app/finders/snippets_finder.rb
@@ -61,25 +61,25 @@ class SnippetsFinder < UnionFinder
# Returns a collection of projects that is either public or visible to the
# logged in user.
#
- # A caller may pass in a block to modify individual parts of
+ # A caller must pass in a block to modify individual parts of
# the query, e.g. to apply .with_feature_available_for_user on top of it.
# This is useful for performance as we can stick those additional filters
# at the bottom of e.g. the UNION.
- def projects_for_user(&block)
- return block.call(Project.public_to_user) unless current_user
+ def projects_for_user
+ return yield(Project.public_to_user) unless current_user
# If the current_user is allowed to see all projects,
# we can shortcut and just return.
- return block.call(Project.all) if current_user.full_private_access?
+ return yield(Project.all) if current_user.full_private_access?
authorized = current_user
.project_authorizations
.select(1)
.where('project_authorizations.project_id = projects.id')
- authorized_projects = block.call(Project.where('EXISTS (?)', authorized))
+ authorized_projects = yield(Project.where('EXISTS (?)', authorized))
levels = Gitlab::VisibilityLevel.levels_for_user(current_user)
- visible_projects = block.call(Project.where(visibility_level: levels))
+ visible_projects = yield(Project.where(visibility_level: levels))
# We use a UNION here instead of OR clauses since this results in better
# performance.