Skip to content
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

Merged
merged 4 commits into from
Dec 15, 2021
Merged

Conversation

sled
Copy link
Contributor

@sled sled commented Dec 12, 2021

Description

Allows callable authorizers to be passed as proposed in #1344

@@ -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)
Copy link
Contributor Author

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.

Copy link
Member

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!

Copy link
Member

@olleolleolle olleolleolle left a 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 <olle.jonsson@gmail.com>
Copy link
Member

@olleolleolle olleolleolle left a 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!

Copy link
Member

@iMacTia iMacTia left a 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)
Copy link
Member

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!

@iMacTia iMacTia merged commit 9ef407a into lostisland:main Dec 15, 2021
jrochkind pushed a commit to jrochkind/faraday that referenced this pull request Dec 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants