module

HardWire::Root

Inherits HardWire::Container

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

Constants

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 methods

registered?(target : Class, tag = "default") : Bool

Interrogate the container for a registration

Source

Macros

resolve(target, tag = "default")

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?

Source
scope(name)

create a new scope with the specified name

Source
scope

Create a new scope with a randomly chosen unique ID

Source
scoped(path, tag = nil, &block)

Register a scoped dependency.

Source
scoped(path, &block)

Register a singleton dependency.

Source
singleton(path, tag = nil, &block)

Register a singleton dependency.

Source
singleton(path, &block)

Register a singleton dependency.

Source
transient(path, tag = nil, &block)

Register a transient dependency.

Source
transient(path, &block)

Register a transient dependency.

Source

Nested types