line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBIx::Model::DB; |
2
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
24
|
|
4
|
1
|
|
|
1
|
|
681
|
use Type::Tiny; |
|
1
|
|
|
|
|
20264
|
|
|
1
|
|
|
|
|
44
|
|
5
|
1
|
|
|
1
|
|
1017
|
use Types::Standard qw/ArrayRef Int Str Undef/; |
|
1
|
|
|
|
|
61693
|
|
|
1
|
|
|
|
|
14
|
|
6
|
1
|
|
|
1
|
|
1797
|
use DBIx::Model::Table; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
1204
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.0.1_2'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my $Table = Type::Tiny->new( |
11
|
|
|
|
|
|
|
name => 'Table', |
12
|
|
|
|
|
|
|
constraint => sub { ref($_) eq 'table' }, |
13
|
|
|
|
|
|
|
message => sub { "$_ ain't a table" }, |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $INLINE = { |
17
|
|
|
|
|
|
|
catalog => { |
18
|
|
|
|
|
|
|
is => 'ro', |
19
|
|
|
|
|
|
|
isa => Str | Undef, |
20
|
|
|
|
|
|
|
}, |
21
|
|
|
|
|
|
|
chains => { |
22
|
|
|
|
|
|
|
is => 'rw', |
23
|
|
|
|
|
|
|
isa => Int, |
24
|
|
|
|
|
|
|
}, |
25
|
|
|
|
|
|
|
_tables => { |
26
|
|
|
|
|
|
|
is => 'ro', |
27
|
|
|
|
|
|
|
isa => ArrayRef [$Table], |
28
|
|
|
|
|
|
|
default => sub { [] }, |
29
|
|
|
|
|
|
|
}, |
30
|
|
|
|
|
|
|
name => { |
31
|
|
|
|
|
|
|
is => 'ro', |
32
|
|
|
|
|
|
|
isa => Str, |
33
|
|
|
|
|
|
|
required => 1, |
34
|
|
|
|
|
|
|
}, |
35
|
|
|
|
|
|
|
schema => { |
36
|
|
|
|
|
|
|
is => 'ro', |
37
|
|
|
|
|
|
|
isa => Str | Undef, |
38
|
|
|
|
|
|
|
}, |
39
|
|
|
|
|
|
|
table_types => { |
40
|
|
|
|
|
|
|
is => 'ro', |
41
|
|
|
|
|
|
|
isa => Str, |
42
|
|
|
|
|
|
|
}, |
43
|
|
|
|
|
|
|
}; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub add_table { |
46
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
47
|
0
|
|
|
|
|
|
my $table = DBIx::Model::Table->new( @_, db => $self ); |
48
|
0
|
|
|
|
|
|
push( @{ $self->_tables }, $table ); |
|
0
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
return $table; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub tables { |
53
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
54
|
0
|
0
|
|
|
|
|
return @{ $self->_tables } if wantarray; |
|
0
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
return $self->_tables; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub as_string { |
59
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
60
|
0
|
|
|
|
|
|
my $str = $self->name; |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
foreach my $table ( $self->tables ) { |
63
|
0
|
|
|
|
|
|
$str .= "\n" . $table->as_string(' '); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
return $str; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
### DO NOT EDIT BELOW! (generated by Class::Inline v0.0.1) |
70
|
|
|
|
|
|
|
#<<< |
71
|
0
|
|
|
0
|
0
|
|
require Carp;our@ATTRS_UNEX=(undef);sub new {my$class=shift;my$self={@_ ? @_ |
72
|
0
|
0
|
|
|
|
|
> 1 ? @_ : %{$_[0]}: ()};map {local$Carp::CarpLevel=$Carp::CarpLevel + 1; |
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Carp::croak("missing attribute DBIx::Model::DB::$_ is required")unless |
74
|
0
|
0
|
|
|
|
|
exists$self->{$_}}'name';if (@ATTRS_UNEX){map {local$Carp::CarpLevel= |
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
$Carp::CarpLevel + 1;Carp::carp("DBIx::Model::DB attribute '$_' unexpected") |
76
|
0
|
|
|
|
|
|
;delete$self->{$_ }}sort grep {not exists$INLINE->{$_ }}keys %$self}else { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
@ATTRS_UNEX=map {delete$self->{$_ };$_}grep {not exists$INLINE->{$_ }}keys % |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
78
|
0
|
|
0
|
|
|
|
$self}bless$self,ref$class || $class;map {$self->{$_ }=eval {$INLINE->{$_ } |
|
0
|
|
|
|
|
|
|
79
|
0
|
0
|
|
|
|
|
->{'isa'}->($self->{$_ })};Carp::croak( |
|
0
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
qq{DBIx::Model::DB::$_ value invalid ($@)})if $@}grep {exists$self->{$_ }} |
|
0
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
'_tables','catalog','chains','name','schema','table_types';$self}sub __ro { |
82
|
0
|
|
|
0
|
|
|
my (undef,undef,undef,$sub)=caller(1);local$Carp::CarpLevel=$Carp::CarpLevel |
|
0
|
|
|
|
|
|
|
83
|
0
|
|
0
|
|
|
|
+ 1;Carp::croak("attribute $sub is read-only (value: '" .($_[1]// 'undef'). |
84
|
0
|
0
|
0
|
0
|
|
|
"')")}sub _tables {$_[0]->__ro($_[1])if @_ > 1;$_[0]{'_tables'}//= eval { |
|
0
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
$INLINE->{'_tables'}->{'isa'}->($INLINE->{'_tables'}->{'default'}->($_[0]))} |
86
|
0
|
0
|
|
|
|
|
;Carp::croak('invalid (DBIx::Model::DB::_tables) default value: ' .$@)if $@; |
87
|
0
|
0
|
0
|
0
|
0
|
|
$_[0]{'_tables'}}sub catalog {$_[0]->__ro($_[1])if @_ > 1;$_[0]{'catalog'}// |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
88
|
0
|
0
|
|
0
|
0
|
|
undef}sub chains {if (@_ > 1){$_[0]{'chains'}=eval {$INLINE->{'chains'}->{ |
|
0
|
|
|
|
|
|
|
89
|
0
|
0
|
|
|
|
|
'isa'}->($_[1])};Carp::croak('invalid (DBIx::Model::DB::chains) value: '.$@) |
|
0
|
|
|
|
|
|
|
90
|
0
|
0
|
0
|
0
|
0
|
|
if $@;return $_[0]}$_[0]{'chains'}// undef}sub name {$_[0]->__ro($_[1])if @_ |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
91
|
0
|
0
|
0
|
0
|
0
|
|
> 1;$_[0]{'name'}}sub schema {$_[0]->__ro($_[1])if @_ > 1;$_[0]{'schema'}// |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
92
|
0
|
0
|
0
|
0
|
0
|
|
undef}sub table_types {$_[0]->__ro($_[1])if @_ > 1;$_[0]{'table_types'}// |
|
0
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
undef} |
94
|
|
|
|
|
|
|
#>>> |
95
|
|
|
|
|
|
|
### DO NOT EDIT ABOVE! (generated by Class::Inline v0.0.1) |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |