Sha256: 8a1a37a9103c38299acbc0cbfeffd29aa8f9323e2fdbdc24034d538ae17b87de
Contents?: true
Size: 865 Bytes
Versions: 2
Compression:
Stored size: 865 Bytes
Contents
module DidYouMean module Correctable attr_reader :frame_binding IGNORED_CALLERS = [ /( |`)missing_name'/, /( |`)safe_constantize'/ ].freeze private_constant :IGNORED_CALLERS def self.included(klass) klass.class_eval do __to_s__ = klass.instance_method(:to_s) define_method(:original_message){ __to_s__.bind(self).call } def to_s msg = original_message.dup bt = caller.first(6) msg << Formatter.new(suggestions).to_s if IGNORED_CALLERS.all? {|ignored| bt.grep(ignored).empty? } msg rescue original_message end end end def suggestions finder.suggestions end def finder @finder ||= DidYouMean.finders[self.class.to_s].new(self) end end end NameError.send(:include, DidYouMean::Correctable)
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
did_you_mean-0.10.0-java | lib/did_you_mean/core_ext/name_error.rb |
did_you_mean-0.10.0 | lib/did_you_mean/core_ext/name_error.rb |