Skip to content

Instantly share code, notes, and snippets.

@xenoterracide
Last active December 25, 2015 22:19
Show Gist options
  • Select an option

  • Save xenoterracide/7048475 to your computer and use it in GitHub Desktop.

Select an option

Save xenoterracide/7048475 to your computer and use it in GitHub Desktop.
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