File Coverage

blib/lib/Database/Async/ORM/Table.pm
Criterion Covered Total %
statement 6 25 24.0
branch n/a
condition 0 8 0.0
subroutine 2 14 14.2
pod 0 12 0.0
total 8 59 13.5


line stmt bran cond sub pod time code
1             package Database::Async::ORM::Table;
2              
3 2     2   186950 use strict;
  2         4  
  2         70  
4 2     2   8 use warnings;
  2         3  
  2         819  
5              
6             our $VERSION = '0.019'; # VERSION
7              
8             sub new {
9 0     0 0   my ($class, %args) = @_;
10 0           bless \%args, $class
11             }
12              
13 0     0 0   sub schema { shift->{schema} }
14 0     0 0   sub name { shift->{name} }
15 0     0 0   sub defined_in { shift->{defined_in} }
16 0     0 0   sub description { shift->{description} }
17 0     0 0   sub tablespace { shift->{tablespace} }
18 0   0 0 0   sub parents { (shift->{parents} //= [])->@* }
19 0   0 0 0   sub fields { (shift->{fields} //= [])->@* }
20 0   0 0 0   sub constraints { (shift->{constraints} //= [])->@* }
21 0     0 0   sub foreign_keys { grep { $_->type eq 'foreign_key' } shift->constraints }
  0            
22             sub primary_keys {
23 0     0 0   my ($self) = @_;
24 0   0       map { $self->field_by_name($_) } ($self->{primary_keys} // [])->@*
  0            
25             }
26              
27             sub field_by_name {
28 0     0 0   my ($self, $name) = @_;
29 0           my ($field) = grep { $_->name eq $name } $self->fields;
  0            
30 0           return $field;
31             }
32              
33             1;
34