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

Fix warning for Ruby 2.7 #19

Merged
merged 1 commit into from
Jan 6, 2020

Conversation

JuanitoFatas
Copy link
Contributor

@JuanitoFatas JuanitoFatas commented Jan 2, 2020

This Pull Request fixes the warning with Ruby 2.7 (similar to ruby-i18n/i18n#486).

I18n.t defined as follows:

def translate(key = nil, *, throw: false, raise: false, locale: nil, **options)

With Ruby 2.7, we need to be explicit to pass in double splat options. Otherwise warning will be thorwn:

/Users/fengdi/.gem/ruby/2.7.0/gems/title-0.0.7/app/helpers/title/title_helper.rb:16: warning: Using the last argument as keyword parameters is deprecated

https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0

Tested on my rails app that this PR removed the warning.

I18n.t defined as follows:

```
def translate(key = nil, *, throw: false, raise: false, locale: nil, **options)
```

With Ruby 2.7, we need to be explicit to pass in double splat options.

https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/
@calebhearth calebhearth merged commit 7bda024 into calebhearth:master Jan 6, 2020
@calebhearth
Copy link
Owner

Thanks!

@JuanitoFatas JuanitoFatas deleted the ruby-27-kwargs branch January 8, 2020 18:00
gabebw added a commit to hotline-webring/hotline-webring that referenced this pull request Jul 2, 2020
We need this PR to prevent warnings from Ruby 2.7:
calebhearth/title#19

Until a new version is released, grab the code directly from GitHub.
gabebw added a commit to hotline-webring/hotline-webring that referenced this pull request Jul 2, 2020
We need this PR to prevent warnings from Ruby 2.7:
calebhearth/title#19

Until a new version is released, grab the code directly from GitHub.
calebhearth added a commit that referenced this pull request Aug 20, 2020
* Make context safe for interpolation by filtering out reserved keys for
  interpolation. See [#15].
* Be explicit that we are passing in double splat options (Fixes
  warnings in Ruby 2.7) See [#19]

[#15]: #15
[#19]: https://github.com/calebthompson/title/pull/19/files
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