NAME

Bread::Board - A solderless way to wire up you application components

SYNOPSIS

use Bread::Board;

my $c = container 'MyApp' => as {

    service 'log_file_name' => "logfile.log";

    service 'logger' => (
        class        => 'FileLogger',
        lifecycle    => 'Singleton',
        dependencies => [
            depends_on('log_file_name'),
        ]
    );
    
    container 'Database' => as {
        service 'dsn'      => "dbi:sqlite:dbname=my-app.db";    
        service 'username' => "user234";
        service 'password' => "****";                                
    
        service 'dbh' => (
            block => sub {
                my $s = shift;
                DBI->connect(
                    $s->param('dsn'),
                    $s->param('username'),
                    $s->param('password'),                  
                ) || die "Could not connect";
            },
            dependencies => wire_names(qw[dsn username password])   
        );
    };

    service 'application' => (
        class        => 'MyApplication',
        dependencies => {
            logger => depends_on('logger'),
            dbh    => depends_on('Database/dbh'),
        }
    );

};

no Bread::Board; # removes keywords

$c->fetch('application')->run;

DESCRIPTION

+-----------------------------------------+
|          A B C D E   F G H I J          |
|-----------------------------------------|
| o o |  1 o-o-o-o-o v o-o-o-o-o 1  | o o |
| o o |  2 o-o-o-o-o   o-o-o-o-o 2  | o o |
| o o |  3 o-o-o-o-o   o-o-o-o-o 3  | o o |
| o o |  4 o-o-o-o-o   o-o-o-o-o 4  | o o |
| o o |  5 o-o-o-o-o   o-o-o-o-o 5  | o o |
|     |  6 o-o-o-o-o   o-o-o-o-o 6  |     |
| o o |  7 o-o-o-o-o   o-o-o-o-o 7  | o o |
| o o |  8 o-o-o-o-o   o-o-o-o-o 8  | o o | 
| o o |  9 o-o-o-o-o   o-o-o-o-o 9  | o o |
| o o | 10 o-o-o-o-o   o-o-o-o-o 10 | o o |
| o o | 11 o-o-o-o-o   o-o-o-o-o 11 | o o |
|     | 12 o-o-o-o-o   o-o-o-o-o 12 |     | 
| o o | 13 o-o-o-o-o   o-o-o-o-o 13 | o o | 
| o o | 14 o-o-o-o-o   o-o-o-o-o 14 | o o | 
| o o | 15 o-o-o-o-o   o-o-o-o-o 15 | o o | 
| o o | 16 o-o-o-o-o   o-o-o-o-o 16 | o o | 
| o o | 17 o-o-o-o-o   o-o-o-o-o 17 | o o | 
|     | 18 o-o-o-o-o   o-o-o-o-o 18 |     | 
| o o | 19 o-o-o-o-o   o-o-o-o-o 19 | o o | 
| o o | 20 o-o-o-o-o   o-o-o-o-o 20 | o o | 
| o o | 21 o-o-o-o-o   o-o-o-o-o 21 | o o |
| o o | 22 o-o-o-o-o   o-o-o-o-o 22 | o o |
| o o | 22 o-o-o-o-o   o-o-o-o-o 22 | o o | 
|     | 23 o-o-o-o-o   o-o-o-o-o 23 |     | 
| o o | 24 o-o-o-o-o   o-o-o-o-o 24 | o o | 
| o o | 25 o-o-o-o-o   o-o-o-o-o 25 | o o | 
| o o | 26 o-o-o-o-o   o-o-o-o-o 26 | o o | 
| o o | 27 o-o-o-o-o   o-o-o-o-o 27 | o o | 
| o o | 28 o-o-o-o-o ^ o-o-o-o-o 28 | o o | 
+-----------------------------------------+

More docs to come, this is a very early release of this module. Basically, if you don't grok the SYNOPSIS then check back later when the docs are written (or feel free to read the tests, the t/02*_sugar.t tests are the most illustrative IMO).

EXPORTED FUNCTIONS

container ($name, &body)
as (&body)
service ($name, $literal|%service_description)
depends_on ($service_name)
wire_names (@service_names)

METHODS

set_root_container ($container)
meta

ACKNOWLEDGEMENTS

Chuck "sprongie" Adams, for testing/using early (pre-release) versions of this module, and some good suggestions for naming it.

Matt "mst" Trout, for finally coming up with the best name for this module.

SEE ALSO

IOC

Bread::Board is basically my re-write of IOC.

http://en.wikipedia.org/wiki/Breadboard

BUGS

All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT.

AUTHOR

Stevan Little <stevan@iinteractive.com>

COPYRIGHT AND LICENSE

Copyright 2007-2008 by Infinity Interactive, Inc.

http://www.iinteractive.com

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.