Module: QueryTracer::Tracer

Extended by:
Tracer
Included in:
Tracer
Defined in:
lib/query_tracer/tracer.rb,
lib/query_tracer/tracer/revision.rb

Defined Under Namespace

Modules: Revision

Instance Method Summary collapse

Instance Method Details

#build_trace(sql) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/query_tracer/tracer.rb', line 7

def build_trace(sql)
  return nil if skip_query?(sql)

  # Include only selected code points
  lines = []
  if QueryTracer.config.multiline
    caller.each {|line| lines << line if include_line?(line)}
  else
    lines << caller.find {|line| include_line?(line)}
  end
  
  unless lines.blank?
    rev = QueryTracer::Tracer::Revision.current
    lines << rev unless rev.blank?
  end
  
  lines
end

#include_line?(line) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/query_tracer/tracer.rb', line 30

def include_line?(line)
  !QueryTracer.config.include_codepoints.select{ |expr| line =~ expr }.blank?
end

#skip_query?(sql) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/query_tracer/tracer.rb', line 26

def skip_query?(sql)
  !QueryTracer.config.exclude_sql.select { |expr| sql =~ expr }.blank?
end