Class: MockSuey::Tracer
- Inherits:
-
Object
- Object
- MockSuey::Tracer
- Defined in:
- lib/mock_suey/tracer.rb
Defined Under Namespace
Classes: PrependCollector, TracePointCollector
Instance Attribute Summary collapse
-
#collector ⇒ Object
readonly
Returns the value of attribute collector.
-
#store ⇒ Object
readonly
Returns the value of attribute store.
-
#targets ⇒ Object
readonly
Returns the value of attribute targets.
Instance Method Summary collapse
- #<<(call_obj) ⇒ Object
- #collect(klass, methods) ⇒ Object
-
#initialize(via: :prepend) ⇒ Tracer
constructor
A new instance of Tracer.
- #start! ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(via: :prepend) ⇒ Tracer
Returns a new instance of Tracer.
124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/mock_suey/tracer.rb', line 124 def initialize(via: :prepend) @store = [] @targets = Hash.new { |h, k| h[k] = [] } @collector = if via == :prepend PrependCollector.new(self) elsif via == :trace_point TracePointCollector.new(self) else raise ArgumentError, "Unknown tracing method: #{via}" end end |
Instance Attribute Details
#collector ⇒ Object (readonly)
Returns the value of attribute collector.
122 123 124 |
# File 'lib/mock_suey/tracer.rb', line 122 def collector @collector end |
#store ⇒ Object (readonly)
Returns the value of attribute store.
122 123 124 |
# File 'lib/mock_suey/tracer.rb', line 122 def store @store end |
#targets ⇒ Object (readonly)
Returns the value of attribute targets.
122 123 124 |
# File 'lib/mock_suey/tracer.rb', line 122 def targets @targets end |
Instance Method Details
#<<(call_obj) ⇒ Object
154 155 156 |
# File 'lib/mock_suey/tracer.rb', line 154 def <<(call_obj) store << call_obj end |
#collect(klass, methods) ⇒ Object
137 138 139 140 |
# File 'lib/mock_suey/tracer.rb', line 137 def collect(klass, methods) targets[klass].concat(methods) targets[klass].uniq! end |
#start! ⇒ Object
142 143 144 |
# File 'lib/mock_suey/tracer.rb', line 142 def start! collector.setup(targets) end |