Class: SourceRoute::Proxy

Inherits:
Object show all
Includes:
Singleton
Defined in:
lib/source_route/proxy.rb

Overview

todo Rename it to Proxy

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeProxy

Returns a new instance of Proxy.



8
9
10
# File 'lib/source_route/proxy.rb', line 8

def initialize
  reset
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



6
7
8
# File 'lib/source_route/proxy.rb', line 6

def config
  @config
end

#result_builderObject

Returns the value of attribute result_builder.



6
7
8
# File 'lib/source_route/proxy.rb', line 6

def result_builder
  @result_builder
end

#tpObject

Returns the value of attribute tp.



6
7
8
# File 'lib/source_route/proxy.rb', line 6

def tp
  @tp
end

Instance Method Details

#resetObject



12
13
14
15
16
17
18
19
# File 'lib/source_route/proxy.rb', line 12

def reset
  @tp.disable if defined? @tp
  @config = Config.new
  # only init once, so its @collected_data seems not useful
  @result_builder = GenerateResult.new(self)
  GenerateResult.clear_wanted_attributes
  self
end

#tp_result_chainObject



31
32
33
# File 'lib/source_route/proxy.rb', line 31

def tp_result_chain
  result_builder.tp_result_chain
end

#traceObject



21
22
23
24
25
26
27
28
29
# File 'lib/source_route/proxy.rb', line 21

def trace
  tp_filter = TpFilter.new(config)
  track = TracePoint.new(*config.event) do |tp|
    next if tp_filter.block_it?(tp)
    @result_builder.output(tp)
  end
  track.enable
  self.tp = track
end