Orochi
view release on metacpan or search on metacpan
lib/Orochi.pm view on Meta::CPAN
class => 'SomeClass',
args => {
bar => $c->bind_value('/myapp/bar')
}
);
$c->inject_literal( '/myapp/bar' => [ 'a', 'b', 'c' ] );
=head1 BEFORE YOU USE THIS MODULE
WARNING: I'd rather use Bread::Board, but I have a need for a particular
kind of DI I<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.
=head1 DESCRIPTION
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.
=head1 USAGE WITH MOOSE CLASSES
This is probably how you'd want to use this module.
Please see L<MooseX::Orochi|MooseX::Orochi> for details
=head1 METHODS
=head2 new(%args)
You may specify the following arguments:
=over 4
=item prefix
If specified, adds a prefix to the given path through C<mangle_path()>.
=back
=head2 get($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.
=head2 mangle_path($path)
Fixes the given path, if necessary. This adds the prefix specified in the
Orochi constructor, for example
=head2 inject($path, $injection_object)
Injects a Orochi::Injection object.
=head2 bind_value($path) or bind_value(\@paths)
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
=head2 inject_constructor($path => %injection_args)
Injects an object constructor. Setter injection also uses this
=head2 inject_literal($path => %injection_args)
Injects a literal value.
=head2 inject_class($class)
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.
=head2 inject_namespace($namespace)
Looks for modules in the given namespace, and calls inject_class on each class.
=head1 SEE ALSO
L<Bread::Board|Bread::Board>
=head1 TODO
Documentation. Samples. Tests.
=head1 AUTHOR
Daisuke Maki C<< <daisuke@endeworks.jp> >>
=head1 LICENSE
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
=cut
( run in 0.772 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )