module T::Private::Methods
def self.set_final_checks_on_hooks(enable)
def self.set_final_checks_on_hooks(enable) is_enabled = !@old_hooks.nil? if enable == is_enabled return end if is_enabled # A cut-down version of T::Private::ClassUtils::ReplacedMethod#restore, because we # should only be resetting final hooks during tests. T::Configuration.without_ruby_warnings do Module.define_method(:included, @old_hooks[0]) Module.define_method(:extended, @old_hooks[1]) Class.define_method(:inherited, @old_hooks[2]) end @old_hooks = nil else old_included = T::Private::ClassUtils.replace_method(Module, :included, true) do |arg| if T::Configuration::AT_LEAST_RUBY_2_7 old_included.bind_call(self, arg) else old_included.bind(self).call(arg) end ::T::Private::Methods._hook_impl(arg, false, self) end old_extended = T::Private::ClassUtils.replace_method(Module, :extended, true) do |arg| if T::Configuration::AT_LEAST_RUBY_2_7 old_extended.bind_call(self, arg) else old_extended.bind(self).call(arg) end ::T::Private::Methods._hook_impl(arg, true, self) end old_inherited = T::Private::ClassUtils.replace_method(Class, :inherited, true) do |arg| if T::Configuration::AT_LEAST_RUBY_2_7 old_inherited.bind_call(self, arg) else old_inherited.bind(self).call(arg) end ::T::Private::Methods._hook_impl(arg, false, self) end @old_hooks = [old_included, old_extended, old_inherited] end end