# class WebConsole::ExceptionMapper

### Public Class Methods

new(exception) click to toggle source

    # File lib/web_console/exception_mapper.rb, line 3
    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 12
    def [](index)
      guess_binding_for_index(index) || @bindings[index]
    end

first() click to toggle source

    # File lib/web_console/exception_mapper.rb, line 8
    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 18
    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 27
    def guess_the_first_application_binding
      @bindings.find do |binding|
        binding.eval('__FILE__').to_s.start_with?(Rails.root.to_s)
      end
    end