Sha256: 71f8df84216186b2eb5868b15b140181e6f076deb76b45e228c0f9535fc3d822
Contents?: true
Size: 786 Bytes
Versions: 3
Compression:
Stored size: 786 Bytes
Contents
require "did_you_mean/spell_checker" module DidYouMean class MethodNameChecker attr_reader :method_name, :receiver NAMES_TO_EXCLUDE = { NilClass => nil.methods } NAMES_TO_EXCLUDE.default = [] def initialize(exception) @method_name = exception.name @receiver = exception.receiver @private_call = exception.respond_to?(:private_call?) ? exception.private_call? : false end def corrections @corrections ||= SpellChecker.new(dictionary: method_names).correct(method_name) - NAMES_TO_EXCLUDE[@receiver.class] end def method_names method_names = receiver.methods + receiver.singleton_methods method_names += receiver.private_methods if @private_call method_names.uniq! method_names end end end
Version data entries
3 entries across 3 versions & 1 rubygems