Sha256: 7d7c42f3b1feb7b66d0931b8f37b3159b83d3ef1519a17c21e25d31253f8108b
Contents?: true
Size: 867 Bytes
Versions: 2
Compression:
Stored size: 867 Bytes
Contents
module DidYouMean class SimilarMethodFinder include BaseFinder attr_reader :method_name, :receiver def initialize(exception) @method_name, @receiver = exception.name, exception.args.first end def words (receiver.methods + receiver.singleton_methods).uniq end alias target_word method_name def format(word) "#{separator}#{word}" end def class_method? receiver.is_a? Class end def separator class_method? ? "." : "#" end end if defined?(RUBY_ENGINE) finders["NoMethodError"] = SimilarMethodFinder case RUBY_ENGINE when 'ruby' require 'did_you_mean/method_missing' when 'jruby' require 'did_you_mean/receiver_capturer' org.yukinishijima.ReceiverCapturer.setup(JRuby.runtime) else finders.delete("NoMethodError") end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
did_you_mean-0.9.2 | lib/did_you_mean/finders/similar_method_finder.rb |
did_you_mean-0.9.0 | lib/did_you_mean/finders/similar_method_finder.rb |