Module: Bootsnap::LoadPathCache::ChangeObserver
- Defined in:
- lib/bootsnap/load_path_cache/change_observer.rb
Defined Under Namespace
Modules: ArrayMixin
Class Method Summary collapse
Class Method Details
.register(arr, observer) ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'lib/bootsnap/load_path_cache/change_observer.rb', line 65 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 |
.unregister(arr) ⇒ Object
74 75 76 77 78 79 80 81 |
# File 'lib/bootsnap/load_path_cache/change_observer.rb', line 74 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 |