Module: DidYouMean::Correctable

Defined in:
lib/did_you_mean/core_ext/name_error.rb

Instance Method Summary collapse

Instance Method Details

#correctionsObject



22
23
24
# File 'lib/did_you_mean/core_ext/name_error.rb', line 22

def corrections
  spell_checker.corrections
end

#original_messageObject



5
6
7
# File 'lib/did_you_mean/core_ext/name_error.rb', line 5

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

#spell_checkerObject



26
27
28
# File 'lib/did_you_mean/core_ext/name_error.rb', line 26

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

#to_sObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/did_you_mean/core_ext/name_error.rb', line 9

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

  if IGNORED_CALLERS.all? {|ignored| bt.grep(ignored).empty? } && (!cause.respond_to?(:corrections) || cause.corrections.empty?)
    msg << Formatter.new(corrections).to_s
  end

  msg
rescue
  super
end