Di::Registry
Inherits Di::KeyParser < Reference < Object
Internal registry for storing providers and tracking shutdown order.
Key format:
- "Type" → default concrete registration
- "Type:name" → named concrete registration
- "~Type:Impl" → interface binding (unnamed)
- "~Type:Impl:name" → interface binding (named)
Thread-safe for multi-threaded Crystal (-Dpreview_mt).
Instance methods
Count implementations for an interface type.
Remove a provider by key (used for rollback on partial registration failure).
Find all named interface providers matching ~Type:Impl:name pattern.
Find all named interface providers keyed by full key.
Find a named interface provider by scanning for ~Type:Impl:name pattern. Raises AmbiguousServiceError if multiple matches, ServiceNotFound if none.
Get a provider by key, raising ServiceNotFound if not registered.
Get all providers for an interface type (keys starting with "~Type:").
Get all providers keyed by full key for deduplication in child scopes.
Get implementation names for an interface type.
Register a provider with the given key. Raises AlreadyRegistered if the key already exists.