Di::Provider::Instance(T)
Inherits Di::Provider::Base < Reference < Object
Generic provider that stores a typed factory and optional singleton cache.
Singleton (default): the factory runs once on first resolve, result is cached. Transient: the factory runs on every resolve, nothing is cached.
Constructors
Instance methods
check_health
Call .healthy? on the cached instance if it responds to it. Returns false if the health probe raises an exception.
reset!
Sourceresolve_typed
Type-safe resolve with circular dependency guard.
The fast-path reads @instance without holding @mutex. This is safe because:
- @instance transitions nil → T exactly once under @mutex in resolve_singleton.
- A stale nil read just falls through to the mutex-protected path.
- @instance is only set to nil again via reset!, which requires no active scopes.
transient?
Source