Class: Orthoses::Railties::Mixin::MultiTracer::MiniTracer

Inherits:
Object
  • Object
show all
Defined in:
lib/orthoses/railties/mixin.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMiniTracer

Returns a new instance of MiniTracer.



20
21
22
23
24
25
26
27
28
# File 'lib/orthoses/railties/mixin.rb', line 20

def initialize
  @depth = []
  @captures = []
  @tp = TracePoint.new(:call) do |tp|
    if @depth.length > 0
      @captures << [tp.self, tp.method_id, tp.binding.local_variable_get(:mods)]
    end
  end
end

Instance Attribute Details

#capturesObject (readonly)

Returns the value of attribute captures.



18
19
20
# File 'lib/orthoses/railties/mixin.rb', line 18

def captures
  @captures
end

Instance Method Details

#popObject



38
39
40
# File 'lib/orthoses/railties/mixin.rb', line 38

def pop
  @depth.pop
end

#pushObject



34
35
36
# File 'lib/orthoses/railties/mixin.rb', line 34

def push
  @depth << true
end

#trace(target:, &block) ⇒ Object



30
31
32
# File 'lib/orthoses/railties/mixin.rb', line 30

def trace(target:, &block)
  @tp.enable(target: target, &block)
end