Skip to content

Use private_method_defined? instead of respond_to? #8

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

Merged
merged 1 commit into from
Jan 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions lib/ruby2_keywords.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class Module
unless respond_to?(:ruby2_keywords, true)
unless private_method_defined?(:ruby2_keywords, true)

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?'

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?'

private
def ruby2_keywords(name, *)
# nil
Expand All @@ -23,12 +23,9 @@ def ruby2_keywords
end

class Hash
unless respond_to?(:ruby2_keywords_hash?)
begin
$VERBOSE, verbose = nil, $VERBOSE
proc {|*a, **h| h}.call(
ensure
$VERBOSE = verbose
unless method_defined?(:ruby2_keywords_hash?)
Copy link
Member

@eregon eregon Jan 19, 2021

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?.

Copy link
Member

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.

def ruby2_keywords_hash?
false
end
end
end