module Bootsnap::LoadPathCache::ChangeObserver
def self.register(arr, observer)
def self.register(arr, observer) return if arr.frozen? # can't register observer, but no need to. arr.instance_variable_set(:@lpc_observer, observer) ArrayMixin.instance_methods.each do |method_name| arr.singleton_class.send(:define_method, method_name, ArrayMixin.instance_method(method_name)) end end
def self.unregister(arr)
def self.unregister(arr) return unless arr.instance_variable_defined?(:@lpc_observer) && arr.instance_variable_get(:@lpc_observer) ArrayMixin.instance_methods.each do |method_name| arr.singleton_class.send(:remove_method, method_name) end arr.instance_variable_set(:@lpc_observer, nil) end