| 1 | package Articulate::Enrichment::DateCreated; | ||||||||||||||||||||
| 2 | 4 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 4 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 4 | ▶ | use Text::Markdown; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 4 | ▶ | use Moo; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | =head1 NAME | ||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | Articulate::Enrichment::DateCreated - add a creation date to the meta | ||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | =head1 METHODS | ||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | =head3 enrich | ||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | Sets the creation date (C<meta.schema.core.dateCreated>) to the current time, unless it already has a defined value. | ||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | =cut | ||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | 4 | ▶ | use DateTime; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | sub _now { | ||||||||||||||||||||
| 24 | 2 | ▶ | DateTime->now; | ||||||||||||||||||
|
Subroutine
_now: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 25 | } | ||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | sub enrich { | ||||||||||||||||||||
| 28 | 2 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
enrich: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||
| 29 | 2 | my $item = shift; | |||||||||||||||||||
| 30 | 2 | my $request = shift; | |||||||||||||||||||
| 31 | 2 | my $now = _now; | |||||||||||||||||||
| 32 | 2 | ▶ | $item->meta->{schema}->{core}->{dateCreated} //= "$now"; | ||||||||||||||||||
|
Condition33%1/3
$item->meta->{"schema"}{"core"}{"dateCreated"} //= "$now"
MC/DC0%0/2
$item->meta->{"schema"}{"core"}{"dateCreated"} //= "$now"
$item->meta->{"schema"}{"core"}{"dateCreated"}
"$now"
Truth table33%1/3
A //= B
A= $item->meta->{"schema"}{"core"}{"dateCreated"}B= "$now"
| |||||||||||||||||||||
| 33 | 2 | return $item; | |||||||||||||||||||
| 34 | } | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 4 | 1; | |||||||||||||||||||