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

Use argument forwarding operator for add_provider #2

Merged
merged 3 commits into from
Nov 22, 2023

Conversation

nilsding
Copy link
Contributor

This resolves an ArgumentError I had with using configurate with Ruby 3.2. For some reason this was still fine until Ruby 3.1:

# frozen_string_literal: true

require 'configurate'
require 'configurate/provider/toml'

Config = Configurate::Settings.create do
  add_provider Configurate::Provider::Env
  add_provider Configurate::Provider::TOML, 'config/app_config.toml', required: false  # this breaks with 3.2
end
ArgumentError: wrong number of arguments (given 2, expected 1)
/Users/foxy/src/some_rails_app/config/initializers/00_config.rb:8:in `block in <main>'
/Users/foxy/src/some_rails_app/config/initializers/00_config.rb:6:in `<main>'
/Users/foxy/src/some_rails_app/config/environment.rb:7:in `<main>'

Solution: use the argument forwarding operator that was shipped with Ruby 2.7.
If support for older Ruby versions is still a requirement there is also the possibility to use ruby2_keywords which was introduced with 2.7 as well, but there is a compatibility gem for that. I created a separate branch with that approach: main...nilsding:configurate:ruby2-keywords

@jhass
Copy link
Owner

jhass commented Nov 21, 2023

Great!

Dropping 2.3 support, we'll need to update https://github.com/jhass/configurate/blob/main/.github/workflows/ci.yml#L17 too :)

@nilsding
Copy link
Contributor Author

nilsding commented Nov 21, 2023

Updated the test matrix, for some reason GitHub does not see the new commit in this PR though. Must be another Monday morning ;-)

@nilsding nilsding marked this pull request as draft November 21, 2023 09:58
@nilsding nilsding marked this pull request as ready for review November 21, 2023 09:58
@nilsding
Copy link
Contributor Author

ah, there's the commit now! 🎉

@jhass
Copy link
Owner

jhass commented Nov 22, 2023

Thank you ❤️

@jhass jhass merged commit b569a14 into jhass:main Nov 22, 2023
4 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