class WebConsole::ExceptionMapper
Attributes
exc[R]
Public Class Methods
find_binding(mappers, exception_object_id)
click to toggle source
# File lib/web_console/exception_mapper.rb, line 17 def self.find_binding(mappers, exception_object_id) mappers.detect do |exception_mapper| exception_mapper.exc.object_id == exception_object_id.to_i end || mappers.first end
follow(exc)
click to toggle source
# File lib/web_console/exception_mapper.rb, line 7 def self.follow(exc) mappers = [new(exc)] while cause = (cause || exc).cause mappers << new(cause) end mappers end
new(exception)
click to toggle source
# File lib/web_console/exception_mapper.rb, line 23 def initialize(exception) @backtrace = exception.backtrace @bindings = exception.bindings @exc = exception end
Public Instance Methods
[](index)
click to toggle source
# File lib/web_console/exception_mapper.rb, line 33 def [](index) guess_binding_for_index(index) || @bindings[index] end
first()
click to toggle source
# File lib/web_console/exception_mapper.rb, line 29 def first guess_the_first_application_binding || @bindings.first end
Private Instance Methods
guess_binding_for_index(index)
click to toggle source
# File lib/web_console/exception_mapper.rb, line 39 def guess_binding_for_index(index) file, line = @backtrace[index].to_s.split(":") line = line.to_i @bindings.find do |binding| source_location = SourceLocation.new(binding) source_location.path == file && source_location.lineno == line end end
guess_the_first_application_binding()
click to toggle source
# File lib/web_console/exception_mapper.rb, line 49 def guess_the_first_application_binding @bindings.find do |binding| source_location = SourceLocation.new(binding) source_location.path.to_s.start_with?(Rails.root.to_s) end end