diff options
| author | Lin Jen-Shin <godfat@godfat.org> | 2017-08-07 16:19:28 +0800 |
|---|---|---|
| committer | Lin Jen-Shin <godfat@godfat.org> | 2017-08-07 16:19:28 +0800 |
| commit | b9a8147333ba3eb6cf4cc83397d61e995b9683e6 (patch) | |
| tree | 7d9140693ea29070967439f5648d8dc958deebf0 /lib/declarative_policy.rb | |
| parent | b3e058996c70aeae6f00cad7195bce421e02b39b (diff) | |
| parent | 03b816f3e845c9b25d3588336fc1616238465deb (diff) | |
| download | gitlab-ce-b9a8147333ba3eb6cf4cc83397d61e995b9683e6.tar.gz | |
Merge remote-tracking branch 'upstream/master' into add-star-for-action-scope
* upstream/master: (184 commits)
Fix issues with pdf-js dependencies
fix missing changelog entries for security release on 2017-01-23
Update top bar issues icon
Fix pipeline icon in contextual nav for projects
Since mysql is not a priority anymore, test it less
Fix order of CI lint ace editor loading
Add container registry and spam logs icons
Fix different Markdown styles
Backport to CE for:
Make new dropdown dividers full width
Fix spec
Fix spec
Fix spec
Bump GITLAB_SHELL_VERSION and GITALY_VERSION to support unhiding refs
Add changelog
Install yarn via apt in update guides
Use long curl options
fix
Add a spec for concurrent process
Remove monkey-patched Array.prototype.first() and last() methods
...
Diffstat (limited to 'lib/declarative_policy.rb')
| -rw-r--r-- | lib/declarative_policy.rb | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/declarative_policy.rb b/lib/declarative_policy.rb index b1eb1a6cef1..ae65653645b 100644 --- a/lib/declarative_policy.rb +++ b/lib/declarative_policy.rb @@ -28,7 +28,13 @@ module DeclarativePolicy subject = find_delegate(subject) - class_for_class(subject.class) + policy_class = class_for_class(subject.class) + raise "no policy for #{subject.class.name}" if policy_class.nil? + policy_class + end + + def has_policy?(subject) + !class_for_class(subject.class).nil? end private @@ -51,9 +57,7 @@ module DeclarativePolicy end end - policy_class = subject_class.instance_variable_get(CLASS_CACHE_IVAR) - raise "no policy for #{subject.class.name}" if policy_class.nil? - policy_class + subject_class.instance_variable_get(CLASS_CACHE_IVAR) end def compute_class_for_class(subject_class) @@ -71,6 +75,8 @@ module DeclarativePolicy nil end end + + nil end def find_delegate(subject) |
