struct Athena::DependencyInjection::ServiceContainer

Overview

Where the instantiated services live.

A getter is defined for each service, if it is public. Otherwise, services are only available via constructor DI.

Defined in:

service_container.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new #

Initializes the container. Auto registering annotated services.


[View source]

Instance Method Detail

def get(type : Service.class) #

Returns an array of services of the provided type.


[View source]
def has?(name : String) : Bool #

Returns true if a service with the provided name has been registered.


[View source]
def resolve(type : _, name : String) : ADI::Service #

Returns the service of the given type and name.

Raises an exception if a service could not be resolved.


[View source]
def tagged(tag : String) #

Returns services with the specified tag.


[View source]
def tags : Hash(String, Array(String)) #

Mapping of tag name to services with that tag.


[View source]