File Coverage

blib/lib/DBIx/Mint/Schema/Class.pm
Criterion Covered Total %
statement 16 16 100.0
branch 4 4 100.0
condition 3 3 100.0
subroutine 5 5 100.0
pod 0 3 0.0
total 28 31 90.3


line stmt bran cond sub pod time code
1             package DBIx::Mint::Schema::Class;
2              
3 15     15   56 use Carp;
  15         16  
  15         815  
4 15     15   57 use Moo;
  15         15  
  15         64  
5              
6             has class => ( is => 'ro', required => 1 );
7             has table => ( is => 'ro', required => 1 );
8             has pk => ( is => 'ro', required => 1 );
9             has fields_not_in_db => ( is => 'rw', default => sub { [] });
10             has auto_pk => ( is => 'ro', predicate => 1 );
11              
12             sub BUILDARGS {
13 31     31 0 12678 my ($class, %args) = @_;
14 31 100       127 $args{pk} = [ $args{pk} ] unless ref $args{pk};
15 31         498 return \%args;
16             }
17              
18             sub BUILD {
19 31     31 0 226 my $self = shift;
20 23         291 croak "Only a single primary key is supported if you use auto-incrementing values"
21 31 100 100     158 if $self->has_auto_pk && @{ $self->pk } > 1;
22 30         66 $self->not_in_db('_name');
23             }
24              
25             sub not_in_db {
26 30     30 0 35 my $self = shift;
27 30         29 push @{ $self->fields_not_in_db }, @_;
  30         527  
28             }
29              
30             1;