lib/Mail/Decency/Core/Meta/Database.pm

filter: Statementstmt 57.1% 8 / 14 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 2 / 3 Podpod 100% 1 / 1 totaltotal 42.3% 11 / 26 CC 5 SCAR 30.8
CC
5
Cov
36%
check_database
30.0
BEGIN
1.0
BEGIN
1.0
CRAP 21.7
« lib/Mail/Decency/Core/DatabaseCreate.pm ↑ Summary lib/Mail/Decency/Core/SessionItem/Policy.pm »
1 package Mail::Decency::Core::Meta::Database;
2  
3 3 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 3 ▶use version 0.74; our $VERSION = qv( "v0.1.4" );
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 =head1 NAME
8  
9 Mail::Decency::Core::Meta::Tables
10  
11 =head1 DESCRIPTION
12  
13 Abstract base class for all modules requiring databases
14  
15  
16 =head1 CLASS ATTRIBUTES
17  
18  
19 =head1 METHODS
20  
21  
22 =head2 check_database
23  
24 Checks database by pinging (connection check) and setting up tables (schema definition)
25  
26 =cut
27  
28 0 ▶sub check_database {
Subroutine check_database: not called CC=5 SCAR=34.0
Pod documented
29 0 my ( $self, $definition_ref ) = @_;
30
31 # check all tables in all schemas ..
32 0 ▶ while( my ( $schema, $tables_ref ) = each %$definition_ref ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$definition_ref) 0 0 0
33 0 ▶ while ( my ( $table, $columns_ref ) = each %$tables_ref ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$tables_ref) 0 0 0
34
35 # ping database ..
36 0 ▶ unless ( $self->database->ping( $schema => $table ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->database->ping($schema, $table)) 0 0 0
37
38 # don't create, die with create syntax error
39 0 ▶ return 0 unless $self->database->setup( $schema => $table => $columns_ref );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->database->setup($schema, $table, $columns_ref) 0 0 0
40 }
41 }
42 }
43
44 0 return 1;
45 }
46  
47 =head1 AUTHOR
48  
49 Ulrich Kautz <uk@fortrabbit.de>
50  
51 =head1 COPYRIGHT
52  
53 Copyright (c) 2010 the L</AUTHOR> as listed above
54  
55 =head1 LICENCSE
56  
57 This library is free software and may be distributed under the same terms as perl itself.
58  
59 =cut
60  
61  
62 3 1;
« lib/Mail/Decency/Core/DatabaseCreate.pm ↑ Summary lib/Mail/Decency/Core/SessionItem/Policy.pm »