Module: Bootsnap::LoadPathCache::ChangeObserver::ArrayMixin

Defined in:
lib/bootsnap/load_path_cache/change_observer.rb

Instance Method Summary collapse

Instance Method Details

#<<(entry) ⇒ Object

For each method that adds items to one end or another of the array (<<, push, unshift, concat), override that method to also notify the observer of the change.



10
11
12
13
# File 'lib/bootsnap/load_path_cache/change_observer.rb', line 10

def <<(entry)
  @lpc_observer.push_paths(self, entry.to_s)
  super
end

#concat(entries) ⇒ Object



27
28
29
30
# File 'lib/bootsnap/load_path_cache/change_observer.rb', line 27

def concat(entries)
  @lpc_observer.push_paths(self, *entries.map(&:to_s))
  super
end

#dupObject Also known as: clone



58
59
60
# File 'lib/bootsnap/load_path_cache/change_observer.rb', line 58

def dup
  [] + self
end

#push(*entries) ⇒ Object Also known as: append



15
16
17
18
# File 'lib/bootsnap/load_path_cache/change_observer.rb', line 15

def push(*entries)
  @lpc_observer.push_paths(self, *entries.map(&:to_s))
  super
end

#uniq!(*args) ⇒ Object

uniq! keeps the first occurrence of each path, otherwise preserving order, preserving the effective load path



34
35
36
37
38
# File 'lib/bootsnap/load_path_cache/change_observer.rb', line 34

def uniq!(*args)
  ret = super
  @lpc_observer.reinitialize if block_given? || !args.empty?
  ret
end

#unshift(*entries) ⇒ Object Also known as: prepend



21
22
23
24
# File 'lib/bootsnap/load_path_cache/change_observer.rb', line 21

def unshift(*entries)
  @lpc_observer.unshift_paths(self, *entries.map(&:to_s))
  super
end