Class: Exceptions::ActiveRecord::StatementInvalid::Handler

Inherits:
ExceptionsBase show all
Defined in:
lib/pry-byetypo/exceptions/active_record/statement_invalid/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.



14
15
16
17
18
# File 'lib/pry-byetypo/exceptions/active_record/statement_invalid/handler.rb', line 14

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

Instance Attribute Details

#exception ⇒ Object (readonly)

Returns the value of attribute exception.



12
13
14
# File 'lib/pry-byetypo/exceptions/active_record/statement_invalid/handler.rb', line 12

def exception
  @exception
end

#output ⇒ Object (readonly)

Returns the value of attribute output.



12
13
14
# File 'lib/pry-byetypo/exceptions/active_record/statement_invalid/handler.rb', line 12

def output
  @output
end

#pry ⇒ Object (readonly)

Returns the value of attribute pry.



12
13
14
# File 'lib/pry-byetypo/exceptions/active_record/statement_invalid/handler.rb', line 12

def pry
  @pry
end

Instance Method Details

#call ⇒ Object

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



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

def call
  case exception.message
  in /#{Constants::Errors::UNDEFINED_TABLE}/
    UndefinedTable.call(output, exception, pry)
  in /#{Constants::Errors::UNDEFINED_COLUMN}/
    UndefinedColumn.call(output, exception, pry)
  else
    Pry::ExceptionHandler.handle_exception(output, exception, pry)
  end
end