Class: RShade::TraceObservable
- Includes:
- Observable
- Defined in:
- lib/rshade/trace_observable.rb
Constant Summary collapse
- CALL_EVENTS =
Set[:call, :c_call, :b_call]
- RETURN_EVENTS =
Set[:return, :c_return, :b_return]
Instance Attribute Summary collapse
-
#trace_p ⇒ Object
readonly
Returns the value of attribute trace_p.
Instance Method Summary collapse
-
#initialize(observers, config) ⇒ TraceObservable
constructor
A new instance of TraceObservable.
- #reveal ⇒ Object
Constructor Details
#initialize(observers, config) ⇒ TraceObservable
Returns a new instance of TraceObservable.
10 11 12 13 14 15 16 17 |
# File 'lib/rshade/trace_observable.rb', line 10 def initialize(observers, config) @trace_p = TracePoint.new(*config.tp_events, &method(:process)) observers = [observers] unless observers.is_a?(Enumerable) observers.each do |observer| add_observer(observer, :call) end end |
Instance Attribute Details
#trace_p ⇒ Object (readonly)
Returns the value of attribute trace_p.
4 5 6 |
# File 'lib/rshade/trace_observable.rb', line 4 def trace_p @trace_p end |
Instance Method Details
#reveal ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/rshade/trace_observable.rb', line 19 def reveal return unless block_given? trace_p.enable yield self ensure trace_p.disable end |