module YARD::Registry

The Registry is the centralized data store for all {CodeObjects} created during parsing. The storage is a key value store with the object’s path (see {CodeObjects::Base#path}) as the key and the object itself as the value. Object paths must be unique to be stored in the Registry. All lookups for objects are done on the singleton Registry instance using the {Registry.at} or {Registry.resolve} methods.

Saving / Loading a Registry

The registry is saved to a “yardoc file” (actually a directory), which can be loaded back to perform any lookups. See {Registry.load!} and {Registry.save} for information on saving and loading of a yardoc file.

Threading Notes

The registry class is a singleton class that is accessed directly in many places across YARD. To mitigate threading issues, YARD (0.6.5+) makes the Registry thread local. This means all access to a registry for a specific object set must occur in the originating thread.

@example Loading the Registry

Registry.load!('/path/to/yardocfile') # loads all objects into memory
Registry.at('YARD::CodeObjects::Base').docstring
# => "+Base+ is the superclass of all code objects ..."

@example Getting an object by a specific path

Registry.at('YARD::CodeObjects::Base#docstring')

@example Performing a lookup on a method anywhere in the inheritance tree

Registry.resolve(P('YARD::CodeObjects::Base'), '#docstring', true)