-
Notifications
You must be signed in to change notification settings - Fork 15
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 private_method_defined? instead of respond_to? #8
Conversation
`Module.respond_to?(:ruby2_keywords, true)` does NOT check if `Module#ruby2_keywords` is available. It worked well because there is toplevel `ruby2_keywords` method, but using `private_method_defined?` is better, I think. Also, this fixes a syntactic error.
@@ -1,5 +1,5 @@ | |||
class Module | |||
unless respond_to?(:ruby2_keywords, true) | |||
unless private_method_defined?(:ruby2_keywords, true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This broke this gem on Ruby 2.5:
ArgumentError: wrong number of arguments (given 2, expected 1)
/usr/local/bundle/gems/ruby2_keywords-0.0.3/lib/ruby2_keywords.rb:2:in `private_method_defined?'
@@ -1,5 +1,5 @@ | |||
class Module | |||
unless respond_to?(:ruby2_keywords, true) | |||
unless private_method_defined?(:ruby2_keywords, true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This broke this gem on Ruby 2.5:
ArgumentError: wrong number of arguments (given 2, expected 1)
/usr/local/bundle/gems/ruby2_keywords-0.0.3/lib/ruby2_keywords.rb:2:in `private_method_defined?'
It also broke TruffleRuby FWIW (notably,
I believe that's incorrect.
i.e., we check if Please revert and re-release. |
proc {|*a, **h| h}.call( | ||
ensure | ||
$VERBOSE = verbose | ||
unless method_defined?(:ruby2_keywords_hash?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's an incorrect check BTW, there is Hash.ruby2_keywords_hash?
and no Hash#ruby2_keywords_hash?
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nobu fixed it in 51c47c0.
Module.respond_to?(:ruby2_keywords, true)
does NOT check ifModule#ruby2_keywords
is available. It worked well because there istoplevel
ruby2_keywords
method, but usingprivate_method_defined?
isbetter, I think.
Also, this fixes a syntactic error.