-
Notifications
You must be signed in to change notification settings - Fork 981
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
Callable authorizers #1345
Callable authorizers #1345
Conversation
@@ -37,7 +38,7 @@ def header_from(type, *params) | |||
raise ArgumentError, "Unexpected params received (got #{params.size} instead of 1)" | |||
else | |||
value = params.first | |||
value = value.call if value.is_a?(Proc) | |||
value = value.call if value.is_a?(Proc) || value.respond_to?(:call) |
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.
The ||
is on purpose, because checking the ancestors of an object should be faster than looking up a method. This way, there should be no performance penalty on existing code bases which use a proc
already.
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.
Love this attention to performance, thanks for caring and explaining!
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.
Thanks for the neat test-case and implementation!
Co-authored-by: Olle Jonsson <[email protected]>
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.
Thanks for putting this together!
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.
LGTM 💯 🎉
@@ -37,7 +38,7 @@ def header_from(type, *params) | |||
raise ArgumentError, "Unexpected params received (got #{params.size} instead of 1)" | |||
else | |||
value = params.first | |||
value = value.call if value.is_a?(Proc) | |||
value = value.call if value.is_a?(Proc) || value.respond_to?(:call) |
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.
Love this attention to performance, thanks for caring and explaining!
Description
Allows callable authorizers to be passed as proposed in #1344