DBomb/Meta/Key.pm

filter: Statementstmt 33.3% 17 / 51 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 41.6% 5 / 12 Podpod 0.0% 0 / 7 totaltotal 29.7% 22 / 74 CC 5 SCAR 16.9
CC
5
Cov
31%
init
12.0
mk_where
12.0
table_info
2.0
CRAP 5.4
« DBomb/Meta/HasQuery.pm ↑ Summary DBomb/Query/OrderBy.pm »
1 package DBomb::Meta::Key;
2  
3 =head1 NAME
4  
5 DBomb::Meta::Key - An vector of columns.
6  
7 =head1 SYNOPSIS
8  
9 =cut
10  
11 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 our $VERSION = '$Revision: 1.13 $';
14  
15 1 ▶use Tie::IxHash;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use Carp::Assert;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 use Class::MethodMaker
18 1 ▶ 'new_with_init' => 'new',
Subroutine BEGIN: called CC=1 SCAR=0.0
19 'get_set' => [qw(columns)], # IxHash{ column_name => column_info }
20 'boolean' => [qw(is_pk)],
21 1 ;
22  
23 ## init( $cols_list, $opts)
24 sub init
25 0 ▶{
Subroutine init: not called CC=3 SCAR=24.8
Pod undocumented
26 0 my ($self, $cols_list, $opts) = @_;
27 0 my %h;
28 0 tie %h, 'Tie::IxHash';
29 0 $self->columns(\%h);
30  
31 0 ▶ $cols_list = [$cols_list] if ref($cols_list) ne 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $cols_list ne "ARRAY" 0 0 0
32 0 for my $cinfo (@$cols_list){
33 0 $self->columns->{$cinfo->name} = $cinfo;
34 }
35  
36 ## Register with table info
37 0 push @{$self->table_info->keys}, $self;
38 }
39  
40 sub table_info
41 0 ▶{
Subroutine table_info: not called CC=1 SCAR=6.9
Pod undocumented
42 0 my $self = shift;
43 0 assert(@_ == 0);
44 0 tied(%{$self->columns})->Values(0)->table_info;
45 }
46  
47 sub columns_list
48 0 ▶{
Subroutine columns_list: not called CC=1 SCAR=6.9
Pod undocumented
49 0 my $self = shift;
50 0 assert(@_ == 0);
51 0 [values %{$self->columns}]
52 }
53  
54 sub column_names
55 0 ▶{
Subroutine column_names: not called CC=1 SCAR=6.9
Pod undocumented
56 0 my $self = shift;
57 0 assert(@_ == 0);
58 0 [keys %{$self->columns}]
59 }
60  
61 sub column_count
62 0 ▶{
Subroutine column_count: not called CC=1 SCAR=6.9
Pod undocumented
63 0 my $self = shift;
64 0 assert(@_ == 0);
65 0 tied(%{$self->columns})->Length;
66 }
67  
68 sub resolve
69 0 ▶{
Subroutine resolve: not called CC=1 SCAR=6.9
Pod undocumented
70 ## No action.
71 0 return 1;
72 }
73  
74 ## returns a where clause optionally with bind values
75 ## mk_where(@bind_values)
76 sub mk_where
77 0 ▶{
Subroutine mk_where: not called CC=3 SCAR=24.8
Pod undocumented
78 0 my $self = shift;
79 0 my $where = new DBomb::Query::Expr();
80  
81 0 for (values %{$self->columns}){
82 0 $where->and(+{$_->fq_name => '?'});
83 }
84 0 ▶ push @{$where->bind_values}, @_ if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
85  
86 0 return $where;
87 }
88  
89  
90 1 1;
91 __END__
« DBomb/Meta/HasQuery.pm ↑ Summary DBomb/Query/OrderBy.pm »