-
-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Skip context memoization when passing explicit context #267
Skip context memoization when passing explicit context #267
Conversation
ab8ac45
to
6263ca9
Compare
record_key = record._policy_cache_key(use_object_id: true) | ||
context_key = context.values.map { _1._policy_cache_key(use_object_id: true) }.join(".") | ||
context_key = context_for_policy(context).values.map { _1._policy_cache_key(use_object_id: true) }.join(".") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Explicit context was not merged with implicit context to compute cache key.
6263ca9
to
4f295f6
Compare
authorization_context.merge(context).tap do | ||
remove_instance_variable :@_authorization_context | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems a bit complicated but it allows to fulfil all the following conditions:
- Keep memoization by default
- Skip memoization when passing an explicit context
- Allow someone to override
authorization_context
- Use any overrided
authorization_context
as the implicit context to merge with in the explicit one.
(See #217 (comment) & #265 (comment))
Thanks for the PR! I decided to go in a bit different direction (to minimize changes). Now available in master. |
Fixes #265 - 2nd suggestion :
Skip memoization when an explicit context is passed.
PR checklist:
Documentation updatedNot required since it's all about internal memoization