class RubyDetective::SourceRepresentation::DependencyResolver

Attributes

classes[R]

Public Class Methods

new() click to toggle source
# File lib/ruby_detective/source_representation/dependency_resolver.rb, line 6
def initialize
  @classes = DataStore.instance.classes
end
resolve_and_populate_store() click to toggle source
# File lib/ruby_detective/source_representation/dependency_resolver.rb, line 10
def self.resolve_and_populate_store
  new.resolve_and_populate_store
end

Public Instance Methods

resolve_and_populate_store() click to toggle source
# File lib/ruby_detective/source_representation/dependency_resolver.rb, line 14
def resolve_and_populate_store
  register_dependencies_and_dependents
  true
end

Private Instance Methods

find_referred_class(constant) click to toggle source
# File lib/ruby_detective/source_representation/dependency_resolver.rb, line 32
def find_referred_class(constant)
  classes.select do |klass|
    constant.possible_paths_of_referenced_entity.find do |possible_path|
      klass.path == possible_path
    end
  end.compact.first
end
register_dependencies_and_dependents() click to toggle source
# File lib/ruby_detective/source_representation/dependency_resolver.rb, line 21
def register_dependencies_and_dependents
  classes.each do |klass|
    klass.constants.each do |constant|
      referred_class = find_referred_class(constant)
      next if referred_class.nil?

      constant.register_referred_class(referred_class)
    end
  end
end