Created
September 29, 2010 04:19
-
-
Save issm/602285 to your computer and use it in GitHub Desktop.
This file contains 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 strict; | |
use warnings; | |
package My::DB; | |
# default setting | |
my $setup = +{ | |
dsn => 'dbi:mysql:test', | |
username => 'user', | |
password => 'passwd', | |
}; | |
sub import { | |
my ($class, %opts) = @_; | |
$setup = $opts{setup} if defined $opts{setup}; | |
} | |
eval << '...'; | |
use DBIx::Skinny setup => $setup; | |
... | |
1; | |
package My::DB::Schema; | |
use base qw/DBIx::Skinny::Schema::Loader/; | |
use DBIx::Skinny::Schema; | |
__PACKAGE__->load_schema; | |
1; | |
__END__ | |
# デフォルト設定で接続 | |
use My::DB; | |
# 設定を指定して接続 | |
use My::DB setup => +{ | |
dsn => 'dbi:mysql:other_test', | |
username => 'other_user', | |
password => 'other_passwd', | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment