File: | blib/lib/MySQL/Util/Lite/Schema.pm |
Coverage: | 62.7% |
line | stmt | bran | cond | sub | code |
---|---|---|---|---|---|
1 | package MySQL::Util::Lite::Schema; | ||||
2 | |||||
3 | our $VERSION = '0.01'; | ||||
4 | |||||
5 | 1 1 1 | use Modern::Perl; | |||
6 | 1 1 1 | use Moose; | |||
7 | 1 1 1 | use namespace::autoclean; | |||
8 | 1 1 1 | use Method::Signatures; | |||
9 | 1 1 1 | use Data::Printer alias => 'pdump'; | |||
10 | 1 1 1 | use MySQL::Util::Lite::Table; | |||
11 | |||||
12 | has name => ( | ||||
13 | is => 'ro', | ||||
14 | isa => 'Str', | ||||
15 | required => 1, | ||||
16 | ); | ||||
17 | |||||
18 | has _util => ( | ||||
19 | is => 'ro', | ||||
20 | isa => 'MySQL::Util', | ||||
21 | required => 1, | ||||
22 | ); | ||||
23 | |||||
24 | 1 0 0 0 0 0 | method get_table (Str $name) { | |||
25 | |||||
26 | 0 | my @tables = $self->get_tables; | |||
27 | 0 | foreach my $t (@tables) { | |||
28 | 0 | if ( $t->name eq $name ) { | |||
29 | 0 | return $t; | |||
30 | } | ||||
31 | } | ||||
32 | } | ||||
33 | |||||
34 | 1 1 1 | method get_tables { | |||
35 | |||||
36 | 1 | my $aref = $self->_util->get_tables; | |||
37 | |||||
38 | 1 | my @ret; | |||
39 | 1 | foreach my $table (@$aref) { | |||
40 | 9 | push @ret, | |||
41 | MySQL::Util::Lite::Table->new( | ||||
42 | name => $table, | ||||
43 | schema_name => $self->name, | ||||
44 | _util => $self->_util | ||||
45 | ); | ||||
46 | } | ||||
47 | |||||
48 | 1 | return @ret; | |||
49 | } | ||||
50 | |||||
51 | 1; |