This repository has been archived by the owner on Jul 5, 2023. It is now read-only.
3/6: Fix generating sigs for mailer with default value #293
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Whelp, I did it. I spent some time figuring out how to parse ruby source code and extract default value for parameters!
I wasted quite a lot of time trying to parse the method signature myself, and learned that it's possible to use Regex for finding matching parenthesis! It's fascinating See: https://stackoverflow.com/questions/546433/regular-expression-to-match-balanced-parentheses#
However, the easier thing to do is using a ruby parser to do this. parser is a really nice library. I also steal some code from parlour's type parser to render a node as string easily.
The end result: we can parse the default value of optional args and optional keyword args! It's beautiful!