Orochi - A DI Container For Perl
use Orochi; my $c = Orochi->new(); $c->inject_constructor('/myapp/foo' => ( class => 'SomeClass', args => { bar => $c->bind_value('/myapp/bar') } ); $c->inject_literal( '/myapp/bar' => [ 'a', 'b', 'c' ] );
WARNING: I'd rather use Bread::Board, but I have a need for a particular kind of DI NOW, and Bread::Board currently doesn't have those features. Therefore here's my version of it.
If/When Bread::Board becomes suitable for my needs, this module may simply be replaced / deleted from CPAN. You've been warned.
Orochi is a simple Dependency Injection -ish system. Orochi in itself is just a big Key/Value store, with a bit of runtime lazy expansion / instantiation of objects mixed in.
This is probably how you'd want to use this module. Please see MooseX::Orochi for details
You may specify the following arguments:
If specified, adds a prefix to the given path through mangle_path().
mangle_path()
Retrieves the value associated with the given $path. If the value needs to be expanded (i.e., create an object), then it will be done automatically.
Fixes the given path, if necessary. This adds the prefix specified in the Orochi constructor, for example
Injects a Orochi::Injection object.
Creates a BindValue injection, which is a lazy evaluation based on a Orochi key.
If given a list, will cascade through the given paths until one returns a defined value
Injects an object constructor. Setter injection also uses this
Injects a literal value.
Injects a MooseX::Orochi based class. The class that is being injected does NOT have to use MooseX::Orochi, as long as one of the meta classes in the inheritance hierarchy does so.
Looks for modules in the given namespace, and calls inject_class on each class.
Bread::Board
Documentation. Samples. Tests.
Daisuke Maki <daisuke@endeworks.jp>
<daisuke@endeworks.jp>
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See http://www.perl.com/perl/misc/Artistic.html
To install Orochi, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Orochi
CPAN shell
perl -MCPAN -e shell install Orochi
For more information on module installation, please visit the detailed CPAN module installation guide.