File Coverage

blib/lib/DBIx/Model/FK.pm
Criterion Covered Total %
statement 12 76 15.7
branch 0 26 0.0
condition 0 7 0.0
subroutine 4 14 28.5
pod 0 7 0.0
total 16 130 12.3


line stmt bran cond sub pod time code
1             package DBIx::Model::FK;
2 1     1   8 use strict;
  1         1  
  1         34  
3 1     1   6 use warnings;
  1         3  
  1         27  
4 1     1   6 use Scalar::Util qw/weaken/;
  1         2  
  1         46  
5 1     1   7 use Types::Standard qw/ArrayRef/;
  1         2  
  1         6  
6              
7             our $VERSION = '0.0.1_2';
8             our $INLINE = {
9             _columns => {
10             is => 'ro',
11             isa => ArrayRef,
12             init_arg => 'columns',
13             required => 1,
14             },
15             table => {
16             is => 'ro',
17             required => 1,
18             weaken => 1,
19             },
20             _to_columns => {
21             is => 'ro',
22             isa => ArrayRef,
23             init_arg => 'to_columns',
24             required => 1,
25             },
26             to_table => {
27             is => 'ro',
28             required => 1,
29             weaken => 1,
30             },
31             };
32              
33             sub BUILD {
34 0     0 0   my $self = shift;
35              
36 0           my @list = @{ $self->_columns };
  0            
37 0           foreach my $i ( 0 .. $#list ) {
38 0           weaken( $self->_columns->[$i] );
39 0           $self->_columns->[$i]->bump_ref_count;
40             }
41              
42 0           @list = @{ $self->_to_columns };
  0            
43 0           foreach my $i ( 0 .. $#list ) {
44 0           weaken( $self->_to_columns->[$i] );
45 0           $self->_to_columns->[$i]->bump_target_count;
46             }
47             }
48              
49             sub as_string {
50 0     0 0   my $self = shift;
51 0           my $prefix = shift;
52             my $str =
53             $prefix
54             . "FOREIGN KEY("
55 0           . join( ',', map { $_->name } $self->columns )
56             . ') REFERENCES '
57             . $self->to_table->name . '('
58 0           . join( ',', map { $_->name } $self->to_columns ) . ')';
  0            
59              
60 0           return $str;
61             }
62              
63             sub columns {
64 0     0 0   my $self = shift;
65 0 0         return @{ $self->_columns } if wantarray;
  0            
66 0           return $self->_columns;
67             }
68              
69             sub to_columns {
70 0     0 0   my $self = shift;
71 0 0         return @{ $self->_to_columns } if wantarray;
  0            
72 0           return $self->_to_columns;
73             }
74              
75             ### DO NOT EDIT BELOW! (generated by Class::Inline v0.0.1)
76             #<<<
77 0     0 0   require Carp;require Scalar::Util;our@ATTRS_UNEX=(undef);sub new {my$class=
78 0 0         shift;my$self={@_ ? @_ > 1 ? @_ : %{$_[0]}: ()};map {local$Carp::CarpLevel=
  0 0          
  0            
  0            
79             $Carp::CarpLevel + 1;Carp::croak(
80 0 0         "missing attribute DBIx::Model::FK::$_ is required")unless exists$self->{$_}
81             }'columns','to_columns','table','to_table';$self->{'_columns'}=delete$self->
82 0 0         {'columns'}if exists$self->{'columns'};$self->{'_to_columns'}=delete$self->{
83 0 0         'to_columns'}if exists$self->{'to_columns'};if (@ATTRS_UNEX){map {local
  0 0          
84 0           $Carp::CarpLevel=$Carp::CarpLevel + 1;Carp::carp(
  0            
85 0           "DBIx::Model::FK attribute '$_' unexpected");delete$self->{$_ }}sort grep {
86 0           not exists$INLINE->{$_ }}keys %$self}else {@ATTRS_UNEX=map {delete$self->{$_
  0            
  0            
87 0   0       };$_}grep {not exists$INLINE->{$_ }}keys %$self}bless$self,ref$class ||
  0            
  0            
  0            
88 0           $class;map {$self->{$_ }=eval {$INLINE->{$_ }->{'isa'}->($self->{$_ })};
  0            
89 0 0         Carp::croak(qq{DBIx::Model::FK::$_ value invalid ($@)})if $@}grep {exists
  0            
90 0           $self->{$_ }}'_columns','_to_columns';map {Scalar::Util::weaken($self->{$_ }
  0            
91 0   0       )}grep {defined$self->{$_ }// undef}'table','to_table';$self}sub __ro {my (
  0            
  0            
92 0     0     undef,undef,undef,$sub)=caller(1);local$Carp::CarpLevel=$Carp::CarpLevel + 1
  0            
93 0   0       ;Carp::croak("attribute $sub is read-only (value: '" .($_[1]// 'undef')."')"
94 0 0   0     )}sub _columns {$_[0]->__ro($_[1])if @_ > 1;$_[0]{'_columns'}}sub
  0            
95 0 0   0 0   _to_columns {$_[0]->__ro($_[1])if @_ > 1;$_[0]{'_to_columns'}}sub table {$_[
  0 0   0      
  0            
96 0 0   0 0   0]->__ro($_[1])if @_ > 1;$_[0]{'table'}}sub to_table {$_[0]->__ro($_[1])if
  0            
97 0           @_ > 1;$_[0]{'to_table'}}
98             #>>>
99             ### DO NOT EDIT ABOVE! (generated by Class::Inline v0.0.1)
100              
101             1;