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


[View source]

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?


[View source]
macro scope(name) #

create a new scope with the specified name


[View source]
macro scope #

Create a new scope with a randomly chosen unique ID


[View source]
macro scoped(path, tag = nil, &block) #

Register a scoped dependency.


[View source]
macro scoped(path, &block) #

Register a singleton dependency.


[View source]
macro singleton(path, tag = nil, &block) #

Register a singleton dependency.


[View source]
macro singleton(path, &block) #

Register a singleton dependency.


[View source]
macro transient(path, tag = nil, &block) #

Register a transient dependency.


[View source]
macro transient(path, &block) #

Register a transient dependency.


[View source]