Class: ExceptionsHandler

Inherits:
Base
  • Object
show all
Defined in:
lib/pry-byetypo/exceptions_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

call, check

Constructor Details

#initialize(output, exception, pry) ⇒ ExceptionsHandler

Returns a new instance of ExceptionsHandler.



13
14
15
16
17
# File 'lib/pry-byetypo/exceptions_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_handler.rb', line 11

def exception
  @exception
end

#outputObject (readonly)

Returns the value of attribute output.



11
12
13
# File 'lib/pry-byetypo/exceptions_handler.rb', line 11

def output
  @output
end

#pryObject (readonly)

Returns the value of attribute pry.



11
12
13
# File 'lib/pry-byetypo/exceptions_handler.rb', line 11

def pry
  @pry
end

Instance Method Details

#callObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/pry-byetypo/exceptions_handler.rb', line 19

def call
  case exception
  in NoMethodError
    Exceptions::NoMethodError.call(output, exception, pry)
  in NameError
    # NameError is a Superclass for all undefined statement.
    Exceptions::NameError::Handler.call(output, exception, pry)
  in ActiveRecord::StatementInvalid
    Exceptions::ActiveRecord::StatementInvalid::Handler.call(output, exception, pry)
  in ActiveRecord::ConfigurationError
    Exceptions::ActiveRecord::ConfigurationError.call(output, exception, pry)
  else
    pry_exception_handler
  end
end