token-master icon indicating copy to clipboard operation
token-master copied to clipboard

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

Open inveterateliterate opened this issue 2 years ago • 0 comments

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 avatar Aug 11 '22 15:08 inveterateliterate