module Tapioca::Runtime::Trackers

def disable_all!

: -> void
def disable_all!
  @trackers.each(&:disable!)
end

def register_tracker(tracker)

: (Tracker tracker) -> void
def register_tracker(tracker)
  @trackers << tracker
end

def with_trackers_enabled(&blk)

: [Return] { -> Return } -> Return
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