Class: SourceRoute::Wrapper
- Includes:
- Singleton
- Defined in:
- lib/source_route/wrapper.rb
Defined Under Namespace
Classes: Condition
Constant Summary collapse
- TRACE_POINT_METHODS =
[:defined_class, :method_id, :path, :lineno]
Instance Attribute Summary collapse
-
#condition ⇒ Object
Returns the value of attribute condition.
-
#result_builder ⇒ Object
Returns the value of attribute result_builder.
-
#tp ⇒ Object
Returns the value of attribute tp.
Instance Method Summary collapse
-
#initialize ⇒ Wrapper
constructor
A new instance of Wrapper.
- #reset ⇒ Object
- #tp_result_chain ⇒ Object
- #trace ⇒ Object
Constructor Details
#initialize ⇒ Wrapper
Returns a new instance of Wrapper.
66 67 68 |
# File 'lib/source_route/wrapper.rb', line 66 def initialize reset end |
Instance Attribute Details
#condition ⇒ Object
Returns the value of attribute condition.
8 9 10 |
# File 'lib/source_route/wrapper.rb', line 8 def condition @condition end |
#result_builder ⇒ Object
Returns the value of attribute result_builder.
8 9 10 |
# File 'lib/source_route/wrapper.rb', line 8 def result_builder @result_builder end |
#tp ⇒ Object
Returns the value of attribute tp.
8 9 10 |
# File 'lib/source_route/wrapper.rb', line 8 def tp @tp end |
Instance Method Details
#reset ⇒ Object
70 71 72 73 74 75 76 |
# File 'lib/source_route/wrapper.rb', line 70 def reset @tp.disable if defined? @tp @condition = Condition.new @result_builder = GenerateResult.new(self) GenerateResult.clear_wanted_attributes self end |
#tp_result_chain ⇒ Object
107 108 109 |
# File 'lib/source_route/wrapper.rb', line 107 def tp_result_chain result_builder.tp_result_chain end |
#trace ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/source_route/wrapper.rb', line 78 def trace # dont wanna init it in tp block, cause tp block could run thousands of times in one cycle trace tp_filter = TpFilter.new(condition) track = TracePoint.new *condition.events do |tp| next if tp_filter.block_it?(tp) # immediate output trace point result # here is confused. todo # should move tp_result_chain to result generator @result_builder.output(tp) # if condition.result_config.format == :console # ret_data = build_result.build(tp) # @tp_result_chain.push(ret_data) # build_result.output(tp) # elsif condition.result_config.format.is_a? Proc # build_result.output(tp) # else # # why not push the tp to result chain # ret_data = build_result.build(tp) # @tp_result_chain.push(ret_data) # end end track.enable self.tp = track end |