Skip to content

Commit

Permalink
add path to "database" file
Browse files Browse the repository at this point in the history
  • Loading branch information
szabgab committed Feb 21, 2013
1 parent 12de6db commit f1007c7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
21 changes: 21 additions & 0 deletions lib/WWW/AdServer/Database.pm
Expand Up @@ -3,4 +3,25 @@ use warnings;
package WWW::AdServer::Database;
use Moo;

has dsn => (
is => 'ro',
required => 1,
);

has type => (
is => 'rw',
);


sub BUILD {
my ($self) = @_;
if (not $self->type) {
if ($self->dsn =~ /\.yml$/) {
$self->type('YAML');
require WWW::AdServer::Database::YAML;
}
}
return;
}

1;
6 changes: 4 additions & 2 deletions t/01-adserver.t
Expand Up @@ -3,13 +3,15 @@ use warnings;

use Test::More;

plan tests => 2;
plan tests => 4;

use WWW::AdServer;

my $ads = WWW::AdServer->new;
isa_ok($ads, 'WWW::AdServer');

my $db = WWW::AdServer::Database->new;
my $db = WWW::AdServer::Database->new(dsn => 't/files/ads.yml');
isa_ok($db, 'WWW::AdServer::Database');
is $db->dsn, 't/files/ads.yml', 'dsn ok';
is $db->type, 'YAML', 'type ok';

0 comments on commit f1007c7

Please sign in to comment.