Skip to content

Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method

TracePoint#disable

() -> bool
[T] () { () -> T } -> T
trace.disable → true or false
trace.disable { block } → obj

Deactivates the trace.

Returns true if the trace was enabled. Returns false if the trace was disabled.

Example
trace.enabled?  #=> true
trace.disable   #=> true (previous status)
trace.enabled?  #=> false
trace.disable   #=> false

If a block is given, the trace will only be disabled within the scope of the block.

Example
trace.enabled?  #=> true

trace.disable do
  trace.enabled?
  # Only disabled for this block
end

trace.enabled?  #=> true

Note: You cannot access event hooks within the block.

Example
trace.disable { p tp.lineno }
#=> RuntimeError: access from outside
See also #defined_class #enable #callee_id #enabled? also in 4.1 · 4.0 · 3.3 · 3.2 · 3.1 · 3.0