lib/tapioca/runtime/trackers.rb in tapioca-0.10.4 vs lib/tapioca/runtime/trackers.rb in tapioca-0.10.5

- old
+ new

@@ -11,9 +11,26 @@ @trackers = T.let([], T::Array[Tracker]) class << self extend T::Sig + sig do + type_parameters(:Return) + .params(blk: T.proc.returns(T.type_parameter(:Return))) + .returns(T.type_parameter(:Return)) + end + def with_trackers_enabled(&blk) + # Currently this is a dirty hack to ensure disabling trackers + # doesn't work while in the block passed to this method. + disable_all_method = method(:disable_all!) + define_singleton_method(:disable_all!) {} + blk.call + ensure + if disable_all_method + define_singleton_method(:disable_all!, disable_all_method) + end + end + sig { void } def disable_all! @trackers.each(&:disable!) end