Skip to content

Commit 52c15f0

Browse files
mamenobu
authored andcommitted
Use private_method_defined? instead of respond_to?
`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 parent 23981c5 commit 52c15f0

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

lib/ruby2_keywords.rb

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class Module
2-
unless respond_to?(:ruby2_keywords, true)
2+
unless private_method_defined?(:ruby2_keywords, true)
33
private
44
def ruby2_keywords(name, *)
55
# nil
@@ -23,12 +23,9 @@ def ruby2_keywords
2323
end
2424

2525
class Hash
26-
unless respond_to?(:ruby2_keywords_hash?)
27-
begin
28-
$VERBOSE, verbose = nil, $VERBOSE
29-
proc {|*a, **h| h}.call(
30-
ensure
31-
$VERBOSE = verbose
26+
unless method_defined?(:ruby2_keywords_hash?)
27+
def ruby2_keywords_hash?
28+
false
3229
end
3330
end
3431
end

0 commit comments

Comments
 (0)