Class: Wait::BaseRescuer
- Inherits:
-
Object
- Object
- Wait::BaseRescuer
- Defined in:
- lib/rescuers/base.rb
Instance Attribute Summary collapse
-
#exceptions ⇒ Object
readonly
Returns the value of attribute exceptions.
-
#logger ⇒ Object
Returns the value of attribute logger.
Instance Method Summary collapse
-
#indent(lines, spaces = 25) ⇒ Object
Indents text a given number of spaces.
-
#initialize(exceptions) ⇒ BaseRescuer
constructor
A new instance of BaseRescuer.
-
#log(exception) ⇒ Object
Logs an exception.
Constructor Details
#initialize(exceptions) ⇒ BaseRescuer
Returns a new instance of BaseRescuer.
6 7 8 |
# File 'lib/rescuers/base.rb', line 6 def initialize(exceptions) @exceptions = Array(exceptions).flatten end |
Instance Attribute Details
#exceptions ⇒ Object (readonly)
Returns the value of attribute exceptions.
4 5 6 |
# File 'lib/rescuers/base.rb', line 4 def exceptions @exceptions end |
#logger ⇒ Object
Returns the value of attribute logger.
3 4 5 |
# File 'lib/rescuers/base.rb', line 3 def logger @logger end |
Instance Method Details
#indent(lines, spaces = 25) ⇒ Object
Indents text a given number of spaces.
24 25 26 |
# File 'lib/rescuers/base.rb', line 24 def indent(lines, spaces = 25) lines.map { |line| (" " * spaces) + line }.join("\n") end |
#log(exception) ⇒ Object
Logs an exception.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rescuers/base.rb', line 11 def log(exception) return if @logger.nil? klass = exception.class.name # We can omit the message if it's identical to the class name. = exception. unless exception. == klass # Indent the exception so it stands apart from the rest of the messages. backtrace = indent(exception.backtrace) @logger.debug("Rescuer") { "rescued: #{klass}#{": #{}" if }\n#{backtrace}" } end |