Commit fcd3e5d4 authored by http://jneen.net/'s avatar http://jneen.net/

cache the cache key...

parent 45e9d287
...@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment