This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use 5.014; | |
| use warnings; | |
| package MyContainer { | |
| use Moose; | |
| use Bread::Board::Declare; | |
| use Bread::Board; | |
| use Bread::Board::Dumper; | |
| use DBIx::Connector; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package MyContainer; | |
| use 5.010; | |
| use Moose; | |
| use Bread::Board::Declare; | |
| has config => ( | |
| isa => 'Config::Merge', | |
| is => 'bare', | |
| lifecycle => 'Singleton' | |
| block => sub { Config::Merge->new('/path/to/config'); }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package MyContainer; | |
| use 5.010; | |
| use Moose; | |
| use Bread::Board::Declare; | |
| sub instance { | |
| state $locator = __PACKAGE__->new; | |
| return $locator; | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package MyContainer; | |
| use 5.010; | |
| use Moose; | |
| use Bread::Board; | |
| sub instance { | |
| state $locator = __PACKAGE__->new; | |
| return $locator; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package Role::DBH; | |
| ... | |
| has _config => ( | |
| isa => 'Config::Merge', | |
| is => 'ro' | |
| lazy => 1, | |
| default => sub { Config::Merge->new('/path/to/config'); }, | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package ProductVariant; | |
| ... | |
| sub _load_categories { | |
| ... | |
| my $config = Config::Merge->new('/path/to/config'); | |
| my $dbh = DBI->connect( $config->('db.dsn'), $config->('db.user'), $config->('db.pass') ); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Package Interface::Create; | |
| use Moose::Role; | |
| use Type::Params qw( compile ); | |
| use Types::Standard qw( slurpy HashRef); | |
| around create => sub { | |
| my $orig = shift; | |
| my $self = shift; | |
| state $check = compile( slurpy HashRef ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package TestBase; | |
| use Moose; | |
| use Bread::Board::Declare; | |
| extends 'Bread::Board::Container'; | |
| __PACKAGE__->meta->make_immutable; | |
| 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package OurApp::BreadBoard; | |
| use Moose; | |
| use Class::Load 0.20 'load_class'; | |
| use Bread::Board::Declare; | |
| has config_file => ( # you can override the location in your .psgi by passing this param to new | |
| isa => 'Str', | |
| is => 'ro', | |
| value => 'my.conf', | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use 5.014; | |
| use warnings; | |
| use Class::Load 'load_class'; | |
| package PaymentGateway { | |
| use Moose; | |
| sub submit { | |
| return int( rand(2) ); | |
| } |