[Catalyst-dev] Catalyst + Bread::Board

André Walker andre at andrewalker.net
Fri Mar 30 01:12:39 GMT 2012


On 03/29/2012 08:44 PM, John Napiorkowski wrote:
> Personally I'm very intrigued by this idea and would love to hear/ see more.  How is this different from say the suggested practice that your contain your domain logic in class (generally I use DBIC) and then pull that into catalyst with a mix of thin adapter classes?
The idea is basically this: (In MyApp::Container)

container {
     model {
         component DBIC => (
                 class        => 'DBIx::Class',
                 lifecycle    => 'Singleton',
                 # other args
         );
         component Logic => ( # all your domain logic, whatever class 
you want here
                 class        => 'My::Domain::Logic',
                 lifecycle    => 'Request',
                 dependencies => {
                     connection => depends_on('DBIC'),
                 },
                 # etc
         );
     }
}

Then you could fetch your components from a crontab script, for 
instance, like this:

perl -MMyApp::Container -e "MyApp::Container->new->resolve(service => 
'model/Logic')->do_stuff"
# magically gets connected, although doesn't load unnecessary dispatch 
stuff, views, etc

And in your Catalyst application, you could have it accessible the old 
usual way:

$ctx->model('DBIC')->foo;
$ctx->model('Logic')->bar;

So, answering your question, the difference is that you don't need the 
adapter class anymore. You can glue it together using a Bread::Board 
container :)



More information about the Catalyst-dev mailing list