Class: Avm::Registry::WithPath::Cache

Inherits:
Object
  • Object
show all
Defined in:
lib/avm/registry/with_path/cache.rb

Instance Method Summary collapse

Instance Method Details

#detect_optional(path) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/avm/registry/with_path/cache.rb', line 13

def detect_optional(path)
  return nil if path.root?
  return cached_paths.fetch(path) if cached_paths.key?(path)

  detected = owner.detect_optional(path)
  detected = detect_optional(path.parent) if detected.blank?
  cached_paths[path] = detected
  detected
end