Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
fcd3e5d4
Commit
fcd3e5d4
authored
Jul 17, 2017
by
http://jneen.net/
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cache the cache key...
parent
45e9d287
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
7 deletions
+8
-7
lib/declarative_policy/condition.rb
lib/declarative_policy/condition.rb
+8
-7
No files found.
lib/declarative_policy/condition.rb
View file @
fcd3e5d4
...
@@ -82,13 +82,14 @@ module DeclarativePolicy
...
@@ -82,13 +82,14 @@ module DeclarativePolicy
# depending on the scope, we may cache only by the user or only by
# depending on the scope, we may cache only by the user or only by
# the subject, resulting in sharing across different policy objects.
# the subject, resulting in sharing across different policy objects.
def
cache_key
def
cache_key
case
@condition
.
scope
@cache_key
||=
when
:normal
then
"/dp/condition/
#{
@condition
.
key
}
/
#{
user_key
}
,
#{
subject_key
}
"
case
@condition
.
scope
when
:user
then
"/dp/condition/
#{
@condition
.
key
}
/
#{
user_key
}
"
when
:normal
then
"/dp/condition/
#{
@condition
.
key
}
/
#{
user_key
}
,
#{
subject_key
}
"
when
:subject
then
"/dp/condition/
#{
@condition
.
key
}
/
#{
subject_key
}
"
when
:user
then
"/dp/condition/
#{
@condition
.
key
}
/
#{
user_key
}
"
when
:global
then
"/dp/condition/
#{
@condition
.
key
}
"
when
:subject
then
"/dp/condition/
#{
@condition
.
key
}
/
#{
subject_key
}
"
else
raise
'invalid scope'
when
:global
then
"/dp/condition/
#{
@condition
.
key
}
"
end
else
raise
'invalid scope'
end
end
end
def
user_key
def
user_key
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment