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:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-05-20 17:34:42 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-05-20 17:34:42 +0300
commit9f46488805e86b1bc341ea1620b866016c2ce5ed (patch)
treef9748c7e287041e37d6da49e0a29c9511dc34768 /lib/declarative_policy.rb
parentdfc92d081ea0332d69c8aca2f0e745cb48ae5e6d (diff)
Add latest changes from gitlab-org/gitlab@13-0-stable-ee
Diffstat (limited to 'lib/declarative_policy.rb')
-rw-r--r--lib/declarative_policy.rb17
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/declarative_policy.rb b/lib/declarative_policy.rb
index e51f30af581..bd1c121fe79 100644
--- a/lib/declarative_policy.rb
+++ b/lib/declarative_policy.rb
@@ -72,18 +72,17 @@ module DeclarativePolicy
end
def compute_class_for_class(subject_class)
+ if subject_class.respond_to?(:declarative_policy_class)
+ return subject_class.declarative_policy_class.constantize
+ end
+
subject_class.ancestors.each do |klass|
- next unless klass.name
+ name = klass.name
+
+ next unless name
begin
- klass_name =
- if subject_class.respond_to?(:declarative_policy_class)
- subject_class.declarative_policy_class
- else
- "#{klass.name}Policy"
- end
-
- policy_class = klass_name.constantize
+ policy_class = "#{name}Policy".constantize
# NOTE: the < operator here tests whether policy_class
# inherits from Base. We can't use #is_a? because that