blib/lib/DBIO/Test/MooseSchema/Result/CD.pm

filter: Statementstmt 100% 9 / 9 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 100% 12 / 12 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/DBIO/Test/MooseSchema/Result/Artist.pm ↑ Summary blib/lib/DBIO/Test/MooseSugarSchema/Result/Artist.pm »
1 package DBIO::Test::MooseSchema::Result::CD;
2 # ABSTRACT: Moose-enabled test result class for the cd table
3  
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 our $VERSION = '0.900007';
8  
9 2 ▶use DBIO::Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 __PACKAGE__->table('cd');
12 __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 __PACKAGE__->set_primary_key('id');
19  
20 __PACKAGE__->belongs_to(
21 artist => 'DBIO::Test::MooseSchema::Result::Artist', 'artist_id'
22 );
23  
24 # Lazy Moose attribute — formatted title including year
25 has full_title => (
26 is => 'ro',
27 isa => 'Str',
28 lazy => 1,
29 builder => '_build_full_title',
30 );
31 sub _build_full_title {
32 my $self = shift;
33 my $year = $self->year // '?';
34 sprintf '%s (%s)', $self->title, $year;
35 }
36  
37 # Moose rw attribute with type constraint and lazy default
38 has rating => ( is => 'rw', isa => 'Int', lazy => 1, default => 0 );
39  
40 __PACKAGE__->meta->make_immutable;
41  
42 1;
43  
44 __END__
« blib/lib/DBIO/Test/MooseSchema/Result/Artist.pm ↑ Summary blib/lib/DBIO/Test/MooseSugarSchema/Result/Artist.pm »