Last active
December 25, 2015 22:19
-
-
Save xenoterracide/7048475 to your computer and use it in GitHub Desktop.
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'); }, | |
| ); | |
| has _dbh => ( | |
| isa => 'DBI::db', | |
| is => 'ro', | |
| lazy => 1, | |
| default => sub { my $self = shift; | |
| DBI->connect( $self->_config->('db.dsn'), $self->_config->('db.user'), $self->_config->('db.pass') ); | |
| }, | |
| ); | |
| package ProductVariant; | |
| with 'Role::DBH'; | |
| sub _load_categories { | |
| ... | |
| $self->_dbh | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment