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.cr

Constant 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

Macro Summary

Class Method Detail

def self.registered?(target : Class, tag = "default") : Bool #

Interrogate the container for a registration


Macro Detail

macro 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?


macro scope(name) #

create a new scope with the specified name


macro scope #

Create a new scope with a randomly chosen unique ID


macro scoped(path, tag = nil, &block) #

Register a scoped dependency.


macro scoped(path, &block) #

Register a singleton dependency.


macro singleton(path, tag = nil, &block) #

Register a singleton dependency.


macro singleton(path, &block) #

Register a singleton dependency.


macro transient(path, tag = nil, &block) #

Register a transient dependency.


macro transient(path, &block) #

Register a transient dependency.