NAME
Kelp::Module::Beam::Wire - Beam::Wire dependency injection container for Kelp
SYNOPSIS
# in config
modules
=> [
qw(Beam::Wire)
],
modules_init
=> {
'Beam::Wire'
=> {
# optional, default is 'app'
app_service
=>
'myapp'
,
# other config for Beam::Wire constructor
},
},
# in your application
my
$app
= MyApp->container->get(
'myapp'
);
DESCRIPTION
This is a very straightforward module that registers the container
method in your Kelp app, accessing a constructed Beam::Wire object.
METHODS INTRODUCED TO KELP
container
my
$beam_wire
=
$kelp
->container;
Returns the Beam::Wire instance.
CONFIGURATION
In addition to special behavior of the configuration fields listed below, all of the configuration from modules_init
is fed to Beam::Wire constructor.
app_service
A name of the service which will hold the instance of the Kelp application itself. By default, value 'app'
is used.
Since Kelp is pretty much a singleton (unless you use "new_anon" in Kelp), you can introduce this method for easy access to the application instance from the class name:
sub
{
shift
->container->get(
'app'
)
}
CAVEATS
Accessing the container from the class name won't work if you use "new_anon" in Kelp to instantiate the application.
SEE ALSO
Kelp, the framework
Beam::Wire, the dependency injection container
AUTHOR
Bartosz Jarzyna, <bbrtj.pro@gmail.com>
COPYRIGHT AND LICENSE
Copyright (C) 2024 by Bartosz Jarzyna
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.