Class: Exceptions::NameError::Handler

Inherits:
ExceptionsBase show all
Defined in:
lib/pry-byetypo/exceptions/name_error/handler.rb

Constant Summary

Constants included from Setup::Store

Setup::Store::DEFAULT_STORE_PATH, Setup::Store::SEVEN_DAYS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Setup::Store

#staled_store?, #store, #store_path

Methods inherited from Base

call, check

Constructor Details

#initialize(output, exception, pry) ⇒ Handler

Returns a new instance of Handler.



13
14
15
16
17
# File 'lib/pry-byetypo/exceptions/name_error/handler.rb', line 13

def initialize(output, exception, pry)
  @output = output
  @exception = exception
  @pry = pry
end

Instance Attribute Details

#exceptionObject (readonly)

Returns the value of attribute exception.



11
12
13
# File 'lib/pry-byetypo/exceptions/name_error/handler.rb', line 11

def exception
  @exception
end

#outputObject (readonly)

Returns the value of attribute output.



11
12
13
# File 'lib/pry-byetypo/exceptions/name_error/handler.rb', line 11

def output
  @output
end

#pryObject (readonly)

Returns the value of attribute pry.



11
12
13
# File 'lib/pry-byetypo/exceptions/name_error/handler.rb', line 11

def pry
  @pry
end

Instance Method Details

#callObject

FIXME: github.com/rubocop/rubocop-performance/issues/438 rubocop:disable Performance/ConstantRegexp



21
22
23
24
25
26
27
28
29
30
# File 'lib/pry-byetypo/exceptions/name_error/handler.rb', line 21

def call
  case exception.message
  in /#{Constants::Errors::UNINITIALIZED_CONSTANT}/
    ActiveRecord::UninitializedConstant.call(output, exception, pry)
  in /#{Constants::Errors::UNDEFINED_VARIABLE}/
    UndefinedVariable.call(output, exception, pry)
  else
    Pry::ExceptionHandler.handle_exception(output, exception, pry)
  end
end