SD/Record.pm untested

filter: Statementstmt 0.0% 0 / 21 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 43 CC 3 SCAR 19.5
CC
3
Cov
0%
canonicalize_prop_created
12.0
BEGIN
2.0
BEGIN
2.0
CRAP 7.0
1 package App::SD::Record;
2 use Any::Moose;
3 use Params::Validate;
4  
5 extends 'Prophet::Record';
6  
7 override declared_props => sub { 'created' };
8  
9 sub canonicalize_prop_created {
10 my $self = shift;
11 my %args = validate(@_, { props => 1, errors => 1});
12  
13 # has the record been created yet? if not, we don't want to try to
14 # get its properties
15 my $props = $self->uuid ? $self->get_props : {};
16  
17 my $created = $args{props}->{created}
18 || $args{props}->{date}
19 || $props->{created}
20 || $props->{date};
21  
22 if (!$created ) {
23 my @now = gmtime();
24  
25 $args{props}->{created} = sprintf(
26 "%04d-%02d-%02d %02d:%02d:%02d",
27 ( $now[5] + 1900 ),
28 ( $now[4] + 1 ),
29 $now[3], $now[2], $now[1], $now[0]
30 );
31  
32 }
33 return 1;
34 }
35  
36 __PACKAGE__->meta->make_immutable;
37 no Any::Moose;
38  
39  
40 1;