Fix the JSON::Coder.new call-seq - #1074
Merged
Merged
Conversation
`JSON` has no `.new`, and options have been keyword arguments since 3.0, so passing a positional Hash raises ArgumentError.
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.
The
JSON::Coder#initializecall-seq is inaccurate in two ways:JSONis a module and has no.new, so the name should beJSON::Coder.new. More substantively, the positionaloptions = nilhas not been accurate since 3.0.0 (28a2b0b), which changed the signature toinitialize(object_class: nil, array_class: nil, on_load: nil, **options, &as_json). Passing options positionally now raises:whereas it worked on 2.x, so the documented form is the one that no longer works. The prose immediately below ("Argument
options, if given, contains a Hash of options") has the same problem, so this updates it to describe keyword arguments.This survived the 3.0 docs pass in 8bdd517, and it is currently what https://docs.ruby-lang.org/en/master/JSON/Coder.html renders. It misled me while migrating Homebrew off
json/add/exception, which is the migration CHANGES.md recommendsJSON::Coderfor, so it seems worth correcting now that more people will be reading this method.Documentation only, no behaviour change.