Class: DevSuite::MethodTracer::Tracer

Inherits:
Object
  • Object
show all
Defined in:
lib/dev_suite/method_tracer/tracer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(show_params: false, show_results: false, show_execution_time: false, max_depth: nil) ⇒ Tracer

Returns a new instance of Tracer.



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/dev_suite/method_tracer/tracer.rb', line 9

def initialize(
  show_params: false,
  show_results: false,
  show_execution_time: false,
  max_depth: nil
)
  @show_params = show_params
  @show_results = show_results
  @show_execution_time = show_execution_time
  @max_depth = max_depth
  @start_times = {}
  @current_depth = 0
end

Instance Attribute Details

#current_depthObject

Returns the value of attribute current_depth.



7
8
9
# File 'lib/dev_suite/method_tracer/tracer.rb', line 7

def current_depth
  @current_depth
end

#max_depthObject (readonly)

Returns the value of attribute max_depth.



6
7
8
# File 'lib/dev_suite/method_tracer/tracer.rb', line 6

def max_depth
  @max_depth
end

#show_execution_timeObject (readonly)

Returns the value of attribute show_execution_time.



6
7
8
# File 'lib/dev_suite/method_tracer/tracer.rb', line 6

def show_execution_time
  @show_execution_time
end

#show_paramsObject (readonly)

Returns the value of attribute show_params.



6
7
8
# File 'lib/dev_suite/method_tracer/tracer.rb', line 6

def show_params
  @show_params
end

#show_resultsObject (readonly)

Returns the value of attribute show_results.



6
7
8
# File 'lib/dev_suite/method_tracer/tracer.rb', line 6

def show_results
  @show_results
end

#start_timesObject

Returns the value of attribute start_times.



7
8
9
# File 'lib/dev_suite/method_tracer/tracer.rb', line 7

def start_times
  @start_times
end

#trace_pointObject

Returns the value of attribute trace_point.



7
8
9
# File 'lib/dev_suite/method_tracer/tracer.rb', line 7

def trace_point
  @trace_point
end

Instance Method Details

#trace(&block) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/dev_suite/method_tracer/tracer.rb', line 23

def trace(&block)
  setup_trace_point
  trace_point.enable
  block.call
ensure
  trace_point&.disable
end