File Coverage

blib/lib/MySQL/Util/Lite/AlternateKey.pm
Criterion Covered Total %
statement 17 29 58.6
branch 0 4 0.0
condition n/a
subroutine 7 9 77.7
pod n/a
total 24 42 57.1


line stmt bran cond sub pod time code
1             package MySQL::Util::Lite::AlternateKey;
2              
3             our $VERSION = '0.01';
4              
5 1     1   6 use Modern::Perl;
  1         2  
  1         8  
6 1     1   154 use Moose;
  1         2  
  1         5  
7 1     1   5862 use namespace::autoclean;
  1         2  
  1         10  
8 1     1   59 use Method::Signatures;
  1         2  
  1         7  
9 1     1   412 use Data::Printer alias => 'pdump';
  1         2  
  1         10  
10              
11             with 'MySQL::Util::Lite::Roles::NewColumn';
12              
13             has name => (
14             is => 'ro',
15             isa => 'Str',
16             required => 1,
17             );
18              
19             has columns => (
20             is => 'rw',
21             isa => 'ArrayRef[MySQL::Util::Lite::Column]',
22             lazy => 1,
23             builder => '_build_columns',
24             );
25              
26             has _util => (
27             is => 'ro',
28             isa => 'MySQL::Util',
29             required => 1,
30             );
31              
32 1 0   1   1822 method get_columns {
  0     0      
  0            
33              
34 0           return @{ $self->columns };
  0            
35             }
36              
37 1 0   1   622 method _build_columns {
  0     0      
  0            
38              
39 0           my $aref = $self->_util->get_constraint( name => $self->name );
40              
41 0           my @cols;
42 0           foreach my $col (@$aref) {
43             my $href = $self->_util->describe_column(
44             table => $col->{TABLE_NAME},
45             column => $col->{COLUMN_NAME}
46 0           );
47 0           push @cols, $self->new_column($href);
48             }
49              
50 0           return \@cols;
51             }
52              
53             1;