Module: Rack::Bug::FilteredBacktrace

Included in:
RedisPanel::Stats::Query, SQLPanel::Query
Defined in:
lib/rack/bug/filtered_backtrace.rb

Instance Method Summary collapse

Instance Method Details

#backtraceObject



5
6
7
# File 'lib/rack/bug/filtered_backtrace.rb', line 5

def backtrace
  @backtrace
end

#filtered_backtraceObject



13
14
15
16
17
18
# File 'lib/rack/bug/filtered_backtrace.rb', line 13

def filtered_backtrace
  @filtered_backtrace ||= @backtrace.map{|l| l.to_s.strip }.select do |line|
    root_for_backtrace_filtering.nil? ||
    (line.index(root_for_backtrace_filtering) == 0) && !(line.index(root_for_backtrace_filtering("vendor")) == 0)
  end
end

#has_backtrace?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/rack/bug/filtered_backtrace.rb', line 9

def has_backtrace?
  filtered_backtrace.any?
end

#root_for_backtrace_filtering(sub_path = nil) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rack/bug/filtered_backtrace.rb', line 20

def root_for_backtrace_filtering(sub_path = nil)
  if defined?(Rails) && Rails.respond_to?(:root)
    (sub_path ? Rails.root.join(sub_path) : Rails.root).to_s
  else
    root = if defined?(RAILS_ROOT)
      RAILS_ROOT
    elsif defined?(ROOT)
      ROOT
    elsif defined?(Sinatra::Application)
      Sinatra::Application.root
    else
      nil
    end
    sub_path ? ::File.join(root, sub_path) : root
  end
end