Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Remove hard-coded list of modules
instead use require and dynamic lookups. Rakudo has supported them for a while now :-)
  • Loading branch information
moritz committed Jan 5, 2015
1 parent cdfeada commit ceed8fb
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions lib/DBIish.pm6
Expand Up @@ -10,15 +10,10 @@ class DBIish:auth<mberends>:ver<0.1.0> {
return $connection;
}
method install_driver( $drivername ) {
my $driver;
given $drivername {
when 'mysql' { EVAL 'use DBDish::mysql; $driver = DBDish::mysql.new()' }
when 'Pg' { EVAL 'use DBDish::Pg; $driver = DBDish::Pg.new()' }
when 'SQLite' { EVAL 'use DBDish::SQLite;$driver = DBDish::SQLite.new()' }
when 'TestMock' { EVAL 'use DBDish::TestMock;$driver = DBDish::TestMock.new()' }
default { die "driver name '$drivername' is not known"; }
}
return $driver;
my $module = "DBDish::$drivername";
require $module;
::($module).new;

}
# TODO: revise error reporting to conform better to Perl 5 DBI
method err() {
Expand Down

0 comments on commit ceed8fb

Please sign in to comment.