Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuana Saskia <starkcoffee@users.noreply.github.com>2018-07-25 14:01:10 +0300
committerDuana Saskia <starkcoffee@users.noreply.github.com>2018-08-13 14:36:22 +0300
commitc322976032e45f02b60701ebf244a8a876063078 (patch)
treeb5e959931ee397e368b679fb5c0f16976141a619 /app/models/concerns/protected_ref.rb
parentece6a1ea6ecffdbde5ff7d663f1ad1eb74f78aa6 (diff)
Refactor ProtectedRefMatcher to be more generic
Diffstat (limited to 'app/models/concerns/protected_ref.rb')
-rw-r--r--app/models/concerns/protected_ref.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/app/models/concerns/protected_ref.rb b/app/models/concerns/protected_ref.rb
index e62e680af6e..af387c99f3d 100644
--- a/app/models/concerns/protected_ref.rb
+++ b/app/models/concerns/protected_ref.rb
@@ -50,14 +50,20 @@ module ProtectedRef
.map(&:"#{action}_access_levels").flatten
end
+ # Returns all protected refs that match the given ref name.
+ # This checks all records from the scope built up so far, and does
+ # _not_ return a relation.
+ #
+ # This method optionally takes in a list of `protected_refs` to search
+ # through, to avoid calling out to the database.
def matching(ref_name, protected_refs: nil)
- ProtectedRefMatcher.matching(self, ref_name, protected_refs: protected_refs)
+ (protected_refs || self.all).select { |protected_ref| protected_ref.matches?(ref_name) }
end
end
private
def ref_matcher
- @ref_matcher ||= ProtectedRefMatcher.new(self)
+ @ref_matcher ||= RefMatcher.new(self.name)
end
end