diff options
author | Jesse Luehrs <doy@tozt.net> | 2011-09-29 13:27:08 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2011-09-29 13:27:08 -0500 |
commit | 88e2fec283e1015a79524ba5d675ab94fa5307ce (patch) | |
tree | 59600e7d6f2f9421a25a5c0cf7b8dd6db58b4b0f /lib/Bread/Board | |
parent | 549a1bdb66ace8f60b66feaffb412572f97ac434 (diff) | |
download | bread-board-declare-88e2fec283e1015a79524ba5d675ab94fa5307ce.tar.gz bread-board-declare-88e2fec283e1015a79524ba5d675ab94fa5307ce.zip |
docs for the dep function
Diffstat (limited to 'lib/Bread/Board')
-rw-r--r-- | lib/Bread/Board/Declare.pm | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/Bread/Board/Declare.pm b/lib/Bread/Board/Declare.pm index 3f5dff5..0d1b6ea 100644 --- a/lib/Bread/Board/Declare.pm +++ b/lib/Bread/Board/Declare.pm @@ -26,6 +26,9 @@ use Bread::Board (); has tt => ( is => 'ro', isa => 'MyApp::View::TT', + dependencies => { + template_root => dep(value => './root/templates'), + }, ); has controller => ( @@ -146,6 +149,33 @@ sub init_meta { $package->$init_meta(%options); } +=head1 EXPORTS + +=head2 dep + + dependencies => { + foo => dep('foo'), + bar => dep(value => 'bar'), + } + +This is a helper function for specifying dependency lists. Passing a single +argument will explicitly mark it as a dependency to be resolved by looking it +up in the container. This isn't strictly necessary (the dependency +specifications for L<Bread::Board> have a coercion which does this +automatically), but being explicit can be easier to understand at times. + +This function can also take a hash of arguments. In that case, an anonymous +service is created to satisfy the dependency. The hash is passed directly to +the constructor for the appropriate service: if the C<value> parameter is +passed, a L<Bread::Board::Literal> service will be created, if the C<block> +parameter is passed, a L<Bread::Board::BlockInjection> service will be created, +and if the C<class> parameter is passed, a +L<Bread::Board::ConstructorInjection> service will be created. Note that these +anonymous services cannot have dependencies themselves, nor can they be +depended on by other services. + +=cut + sub dep { if (@_ > 1) { my %opts = ( |