Prawn::View#method_missing drops keyword arguments on Ruby 3.x - #1284
Closed
Burgestrand wants to merge 1 commit into
Closed
Prawn::View#method_missing drops keyword arguments on Ruby 3.x#1284Burgestrand wants to merge 1 commit into
Burgestrand wants to merge 1 commit into
Conversation
Come Ruby 3.x, keyword arguments will not be part of `*arguments` any more. We could either: 1. Mark the method with `ruby2_keywords`, which would make keyword arguments part of `*arguments` again. However, this is going away in the future so it's a crutch if anything. 2. Make the method properly support keyword arguments. Option 2 is chosen here.
Member
|
@Burgestrand Thank you for your contribution. This was merged outside of GitHub. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Hi! This is my first message about this issue — I figured starting with a PR would make the issue more clear. I'm betting on CI running this code on older versions of Ruby to make sure this doesn't break anything by accident.
Ruby 3.x changes behavior of keyword arguments when used with single splat
*arguments.Prawn::View#method_missingdelegates missing methods to the document, but keyword arguments are dropped in the delegation in Ruby 3.There aren't that many Prawn::Document methods that takes keyword arguments (I pretty much only found the gradient methods). We ran into this in our own code because we've added a few helper methods to Prawn::Document that does take keyword arguments, and we noticed in our upgrade to Ruby 3.x we couldn't use those methods.
In our own code we've temporarily fixed this with a monkey patch:
Here's an example of behavior changed in Ruby 3.x vs 2.x: