| 1 | package DBIO::Test::MooSchema::Result::CD; | ||||||||||||
| 2 | # ABSTRACT: Moo-enabled test result class for the cd table | ||||||||||||
| 3 | |||||||||||||
| 4 | 4 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 4 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | |||||||||||||
| 7 | 4 | our $VERSION = '0.900007'; | |||||||||||
| 8 | |||||||||||||
| 9 | 4 | ▶ | use DBIO::Moo; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | |||||||||||||
| 11 | 4 | __PACKAGE__->table('cd'); | |||||||||||
| 12 | 4 | __PACKAGE__->add_columns( | |||||||||||
| 13 | id => { data_type => 'integer', is_auto_increment => 1 }, | ||||||||||||
| 14 | artist_id => { data_type => 'integer', is_nullable => 0 }, | ||||||||||||
| 15 | title => { data_type => 'varchar', size => 100, is_nullable => 0 }, | ||||||||||||
| 16 | year => { data_type => 'integer', is_nullable => 1 }, | ||||||||||||
| 17 | ); | ||||||||||||
| 18 | 4 | __PACKAGE__->set_primary_key('id'); | |||||||||||
| 19 | |||||||||||||
| 20 | 4 | __PACKAGE__->belongs_to( | |||||||||||
| 21 | artist => 'DBIO::Test::MooSchema::Result::Artist', 'artist_id' | ||||||||||||
| 22 | ); | ||||||||||||
| 23 | |||||||||||||
| 24 | # Lazy Moo attribute — formatted title including year | ||||||||||||
| 25 | 4 | has full_title => ( is => 'lazy' ); | |||||||||||
| 26 | 1 | ▶ | sub _build_full_title { | ||||||||||
|
Subroutine
_build_full_title: called CC=2 SCAR=7.1
| |||||||||||||
| 27 | 1 | my $self = shift; | |||||||||||
| 28 | 1 | ▶ | my $year = $self->year // '?'; | ||||||||||
|
Condition50%1/2
$self->year // "?"
MC/DC0%0/1
$self->year // "?"
$self->year
Truth table50%1/2
A
A= $self->year
| |||||||||||||
| 29 | 1 | sprintf '%s (%s)', $self->title, $year; | |||||||||||
| 30 | } | ||||||||||||
| 31 | |||||||||||||
| 32 | # Moo rw attribute with lazy default | ||||||||||||
| 33 | 1 | ▶ | has rating => ( is => 'rw', lazy => 1, default => sub { 0 } ); | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 34 | |||||||||||||
| 35 | 4 | 1; | |||||||||||
| 36 | |||||||||||||
| 37 | __END__ | ||||||||||||