From 88e2fec283e1015a79524ba5d675ab94fa5307ce Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Thu, 29 Sep 2011 13:27:08 -0500 Subject: docs for the dep function --- lib/Bread/Board/Declare.pm | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) 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 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 parameter is +passed, a L service will be created, if the C +parameter is passed, a L service will be created, +and if the C parameter is passed, a +L 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 = ( -- cgit v1.2.3