| 1 | package Catmandu::Plugin::Datestamps; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 2 | ▶ | use Catmandu::Sane; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 2 | our $VERSION = '1.2025'; | |||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 2 | ▶ | use Catmandu::Util qw(check_string now); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 2 | ▶ | use Moo::Role; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | 2 | ▶ | use MooX::Aliases; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | 2 | ▶ | use namespace::clean; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 2 | has datestamp_format => (is => 'lazy'); | |||||||||||||||||||
| 13 | 2 | has datestamp_created_key => ( | |||||||||||||||||||
| 14 | is => 'lazy', | ||||||||||||||||||||
| 15 | isa => \&check_string, | ||||||||||||||||||||
| 16 | alias => 'datestamp_created_field', | ||||||||||||||||||||
| 17 | ); | ||||||||||||||||||||
| 18 | 2 | has datestamp_updated_key => ( | |||||||||||||||||||
| 19 | is => 'lazy', | ||||||||||||||||||||
| 20 | isa => \&check_string, | ||||||||||||||||||||
| 21 | alias => 'datestamp_updated_field', | ||||||||||||||||||||
| 22 | ); | ||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | 6 | ▶ | before add => sub { | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||||||||||||
| 25 | 6 | my ($self, $data) = @_; | |||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | 6 | my $now = now($self->datestamp_format); | |||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | 6 | ▶ | $data->{$self->datestamp_created_key} ||= $now; | ||||||||||||||||||
|
Condition66%2/3
$$data{$self->datestamp_created_key} ||= $now
MC/DC0%0/2
$$data{$self->datestamp_created_key} ||= $now
$$data{$self->datestamp_created_key}
$now
Truth table66%2/3
A ||= B
A= $$data{$self->datestamp_created_key}B= $now
| |||||||||||||||||||||
| 30 | 6 | $data->{$self->datestamp_updated_key} = $now; | |||||||||||||||||||
| 31 | 2 | }; | |||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | 2 | ▶ | sub _build_datestamp_format {'iso_date_time'} | ||||||||||||||||||
|
Subroutine
_build_datestamp_format: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 34 | 4 | ▶ | sub _build_datestamp_created_key {'date_created'} | ||||||||||||||||||
|
Subroutine
_build_datestamp_created_key: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 35 | 4 | ▶ | sub _build_datestamp_updated_key {'date_updated'} | ||||||||||||||||||
|
Subroutine
_build_datestamp_updated_key: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | 2 | 1; | |||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | __END__ | ||||||||||||||||||||