module HardWire::Root
Overview
A pre-made Container, designed to provide a concrete in-namespace module to generate documentation from.
NOTE All of the methods in this library are designed to operate inside the container class, so you cannot use this container for actual dependency injection
Included Modules
Defined in:
hardwire.crConstant Summary
-
REGISTRATIONS =
[] of NamedTuple(type: String, tag: String, lifecycle: Symbol)
-
Store all registrations, which are mainly used to give nice errors for duplicate registrations
Users can also run their own checks at runtime for length, structure, etc.
Class Method Summary
-
.registered?(target : Class, tag = "default") : Bool
Interrogate the container for a registration
Macro Summary
-
resolve(target, tag = "default")
Resolve a dependency from a class and a string tag
-
scope(name)
create a new scope with the specified name
-
scope
Create a new scope with a randomly chosen unique ID
-
scoped(path, tag = nil, &block)
Register a scoped dependency.
-
scoped(path, &block)
Register a singleton dependency.
-
singleton(path, tag = nil, &block)
Register a singleton dependency.
-
singleton(path, &block)
Register a singleton dependency.
-
transient(path, tag = nil, &block)
Register a transient dependency.
-
transient(path, &block)
Register a transient dependency.
Class Method Detail
Interrogate the container for a registration
Macro Detail
Resolve a dependency from a class and a string tag
This macro does the legwork of mangling the dynamic-looking call into the statically-defined resolve!
method
NOTE This method does not protect you from unregistered dependencies, since it relies on
directly resolving the resolve!
method. If you need safety - use .registered?