Sha256: 0c47269abfad2caef183e5cd013a1ed8efeb8f0d07dc7b636c71096b997397dc

Contents?: true

Size: 551 Bytes

Versions: 2

Compression:

Stored size: 551 Bytes

Contents

module DidYouMean
  module Correctable
    prepend_features NameError
    attr_reader :frame_binding

    def original_message
      method(:to_s).super_method.call
    end

    def to_s
      msg = super.dup
      bt  = caller(1, 6)

      msg << Formatter.new(corrections).to_s if IGNORED_CALLERS.all? {|ignored| bt.grep(ignored).empty? }
      msg
    rescue
      super
    end

    def corrections
      spell_checker.corrections
    end

    def spell_checker
      @spell_checker ||= SPELL_CHECKERS[self.class.to_s].new(self)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
did_you_mean-1.0.0.beta3 lib/did_you_mean/core_ext/name_error.rb
did_you_mean-1.0.0.beta2 lib/did_you_mean/core_ext/name_error.rb