File Coverage

blib/lib/Rubric/DBI.pm
Criterion Covered Total %
statement 18 21 85.7
branch n/a
condition n/a
subroutine 6 7 85.7
pod 1 1 100.0
total 25 29 86.2


line stmt bran cond sub pod time code
1 12     12   4602 use strict;
  12         23  
  12         389  
2 12     12   53 use warnings;
  12         21  
  12         513  
3             package Rubric::DBI;
4             # ABSTRACT: Rubric's subclass of Class::DBI
5             $Rubric::DBI::VERSION = '0.155';
6             # =head1 DESCRIPTION
7             #
8             # Rubric::DBI subclasses Class::DBI. It sets the connection by using the DSN
9             # retrieved from Rubric::Config.
10             #
11             # =cut
12              
13 12     12   54 use Rubric::Config;
  12         19  
  12         68  
14 12     12   16293 use Class::DBI 0.96;
  12         846763  
  12         142  
15 12     12   506 use base qw(Class::DBI);
  12         25  
  12         892  
16              
17 12     12   10404 use Class::DBI::AbstractSearch;
  12         316414  
  12         2435  
18              
19             DBI->trace(Rubric::Config->dbi_trace_level, Rubric::Config->dbi_trace_file);
20              
21             my $dsn = Rubric::Config->dsn;
22             my $db_user = Rubric::Config->db_user;
23             my $db_pass = Rubric::Config->db_pass;
24              
25             __PACKAGE__->connection(
26             $dsn,
27             $db_user,
28             $db_pass,
29             { AutoCommit => 1 }
30             );
31              
32             # =head1 METHODS
33             #
34             # =head2 vacuum
35             #
36             # This method performs periodic maintenance, cleaning up records that are no
37             # longer needed.
38             #
39             # =cut
40              
41             sub vacuum {
42 0     0 1   my $self = shift;
43 0           my $dbh = $self->db_Main;
44 0           my $pruned_links = $dbh->do(
45             "DELETE FROM links WHERE id NOT IN ( SELECT link FROM entries )"
46             );
47             }
48              
49             1;
50              
51             __END__