From: André Walker Date: Wed, 10 Aug 2011 17:59:59 +0000 (-0300) Subject: synopsis for Catalyst::IOC X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4e4e003e3c915e6e4d3b9f2a97c0d458ffa4ae9c;hp=7e3dbfeacccdeee916d640cd15a037a17dda2194;p=catagits%2FCatalyst-Runtime.git synopsis for Catalyst::IOC --- diff --git a/lib/Catalyst/IOC.pm b/lib/Catalyst/IOC.pm index fdbea05..a204295 100644 --- a/lib/Catalyst/IOC.pm +++ b/lib/Catalyst/IOC.pm @@ -39,6 +39,8 @@ Moose::Exporter->setup_import_methods( 1; +# FIXME - should the code example below be on this file or Catalyst::IOC::Container? + __END__ =pod @@ -49,6 +51,41 @@ Catalyst::IOC - IOC for Catalyst, based on Bread::Board =head1 SYNOPSIS + package MyApp::Container; + use Catalyst::IOC; + + sub BUILD { + my $self = shift; + + container $self => as { + container model => as { + + # default component + component Foo => (); + + # model Bar needs model Foo to be built before + # and Bar's constructor gets Foo as a parameter + component Bar => ( dependencies => [ + depends_on('/model/Foo'), + ]); + + # Baz is rebuilt once per HTTP request + component Baz => ( lifecycle => 'Request' ); + + # built only once per application life time + component Quux => ( lifecycle => 'Singleton' ); + + # built once per app life time and uses an external model, + # outside the default directory + # no need for wrappers or Catalyst::Model::Adaptor + component Fnar => ( + lifecycle => 'Singleton', + class => 'My::External::Class', + ); + }; + } + } + =head1 DESCRIPTION =head1 METHODS @@ -57,6 +94,10 @@ Catalyst::IOC - IOC for Catalyst, based on Bread::Board Catalyst Contributors, see Catalyst.pm +=head1 SEE ALSO + +L + =head1 COPYRIGHT This library is free software. You can redistribute it and/or modify it under