Class: Rigor::Environment::RbsHierarchy

Inherits:
Object
  • Object
show all
Defined in:
lib/rigor/environment/rbs_hierarchy.rb

Overview

Small hierarchy oracle backed by RBS instance definitions.

Instance Method Summary collapse

Constructor Details

#initialize(loader) ⇒ RbsHierarchy

Returns a new instance of RbsHierarchy.



7
8
9
10
11
# File 'lib/rigor/environment/rbs_hierarchy.rb', line 7

def initialize(loader)
  @loader = loader
  @ancestor_names_cache = {}
  @class_ordering_cache = {}
end

Instance Method Details

#class_ordering(lhs, rhs) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/rigor/environment/rbs_hierarchy.rb', line 13

def class_ordering(lhs, rhs)
  lhs = normalize_name(lhs)
  rhs = normalize_name(rhs)
  return :equal if lhs == rhs

  key = [lhs, rhs]
  return @class_ordering_cache[key] if @class_ordering_cache.key?(key)

  @class_ordering_cache[key] = compute_class_ordering(lhs, rhs)
end