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

Allow encode/2 to receive opts in any order #112

Merged
merged 3 commits into from
Dec 6, 2023
Merged

Conversation

rewritten
Copy link
Contributor

@rewritten rewritten commented Dec 5, 2023

The usual understanding, when a function accepts a keyword list as a last "options" argument, is that those options can be given in any order. On the other side, the current code pattern matches the list in exact order, so this expectation is not fulfilled, and this code raises a FunctionClauseError:

Avrora.encode(payload, format: :plain, schema_name: "io.confluent.Messenger")

This PR switches out the pattern matching on options, and uses appropriate Keyword functions to extract the values.

@Strech
Copy link
Owner

Strech commented Dec 6, 2023

@rewritten Thanks a lot for the fix. I've changed an approach and for just 2 options, I would prefer pattern matching as a faster way. In addition, I've changed the test description to follow an established format.

💜

@Strech Strech merged commit 5fe9b71 into Strech:master Dec 6, 2023
9 checks passed
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.

2 participants