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

Ruby >=3 handles positional args vs keyword args differently, users may run into an error with the comments in the config #56

Open
inveterateliterate opened this issue Aug 11, 2022 · 0 comments

Comments

@inveterateliterate
Copy link
Contributor

inveterateliterate commented Aug 11, 2022

Initializer Template includes guidance liek the below:

# Examples:
  # config.add_tokenable_options :confirm, TokenMaster::Config::DEFAULT_VALUES

However, because of the way the second argument (a hash) is deconstructed in lib/config:

def add_tokenable_options(key, **params)
      @options[key] = params
    end

This results in a conflict with the way Ruby 3.1 is passing those options along:
https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/

The fix for the user is to splat their options in the initializer like so:
config.add_tokenable_options :confirm, **TokenMaster::Config::DEFAULT_VALUES

creating an issue in here in case there's an option to update the core code to support either approaches, for example not double-splatting and setting the default to be the TokenMaster default

@inveterateliterate inveterateliterate changed the title Rails 3 handles hashs vs keyword args differently, users may run into an error with the comments in the config Ruby >=3 handles positional args vs keyword args differently, users may run into an error with the comments in the config Aug 11, 2022
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

No branches or pull requests

1 participant