mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Do not attempt to call methods on the receiver if it is a basic object
This commit is contained in:
parent
88ee375dd6
commit
18d3b5a93a
1 changed files with 13 additions and 5 deletions
|
@ -43,14 +43,22 @@ module DidYouMean
|
||||||
end
|
end
|
||||||
|
|
||||||
def corrections
|
def corrections
|
||||||
@corrections ||= SpellChecker.new(dictionary: RB_RESERVED_WORDS + method_names).correct(method_name) - NAMES_TO_EXCLUDE[@receiver.class]
|
@corrections ||= SpellChecker.new(dictionary: RB_RESERVED_WORDS + method_names).correct(method_name) - names_to_exclude
|
||||||
end
|
end
|
||||||
|
|
||||||
def method_names
|
def method_names
|
||||||
|
if Object === receiver
|
||||||
method_names = receiver.methods + receiver.singleton_methods
|
method_names = receiver.methods + receiver.singleton_methods
|
||||||
method_names += receiver.private_methods if @private_call
|
method_names += receiver.private_methods if @private_call
|
||||||
method_names.uniq!
|
method_names.uniq!
|
||||||
method_names
|
method_names
|
||||||
|
else
|
||||||
|
[]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def names_to_exclude
|
||||||
|
Object === receiver ? NAMES_TO_EXCLUDE[receiver.class] : []
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue