Class: Derketo::Tracer
- Inherits:
-
Object
- Object
- Derketo::Tracer
- Defined in:
- lib/derketo/tracer.rb
Instance Attribute Summary collapse
-
#events ⇒ Object
Returns the value of attribute events.
Instance Method Summary collapse
-
#initialize(scope: nil) ⇒ Tracer
constructor
A new instance of Tracer.
- #trace ⇒ Object
Constructor Details
#initialize(scope: nil) ⇒ Tracer
Returns a new instance of Tracer.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/derketo/tracer.rb', line 7 def initialize(scope: nil) @events = Derketo::EventTrace.new @tracepoint = TracePoint.new(:call, :return) do |tp| if scope.nil? || tp.path.include?(scope) if tp.event == :call @events.push(Derketo::Events::Call.new(tp)) elsif tp.event == :return @events.push(Derketo::Events::Return.new(tp)) end end end end |
Instance Attribute Details
#events ⇒ Object
Returns the value of attribute events.
6 7 8 |
# File 'lib/derketo/tracer.rb', line 6 def events @events end |
Instance Method Details
#trace ⇒ Object
20 21 22 23 24 25 |
# File 'lib/derketo/tracer.rb', line 20 def trace @tracepoint.enable response = yield @tracepoint.disable response end |