class WebConsole::ExceptionMapper

Public Class Methods

new(exception) click to toggle source
# File lib/web_console/exception_mapper.rb, line 5
def initialize(exception)
  @backtrace = exception.backtrace
  @bindings = exception.bindings
end

Public Instance Methods

[](index) click to toggle source
# File lib/web_console/exception_mapper.rb, line 14
def [](index)
  guess_binding_for_index(index) || @bindings[index]
end
first() click to toggle source
# File lib/web_console/exception_mapper.rb, line 10
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 20
def guess_binding_for_index(index)
  file, line = @backtrace[index].to_s.split(":")
  line = line.to_i

  @bindings.find do |binding|
    binding.eval("__FILE__") == file && binding.eval("__LINE__") == line
  end
end
guess_the_first_application_binding() click to toggle source
# File lib/web_console/exception_mapper.rb, line 29
def guess_the_first_application_binding
  @bindings.find do |binding|
    binding.eval("__FILE__").to_s.start_with?(Rails.root.to_s)
  end
end