Module: Tapioca::ConstantLocator

Defined in:
lib/tapioca/constant_locator.rb

Overview

Registers a TracePoint immediately upon load to track points at which classes and modules are opened for definition. This is used to track correspondence between classes/modules and files, as this information isn't available in the ruby runtime without extra accounting.

Class Method Summary collapse

Class Method Details

.files_for(klass) ⇒ Object

Returns the files in which this class or module was opened. Doesn't know about situations where the class was opened prior to +require+ing, or where metaprogramming was used via eval, etc.



29
30
31
32
33
# File 'lib/tapioca/constant_locator.rb', line 29

def files_for(klass)
  name = String === klass ? klass : NAME.bind(klass).call
  files = @class_files[name]
  files || Set.new
end