| 1 | package DBIO::Test::MooSchema::Result::Artist; | ||
| 2 | # ABSTRACT: Moo-enabled test result class for the artist 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('artist'); | |
| 12 | 4 | __PACKAGE__->add_columns( | |
| 13 | id => { data_type => 'integer', is_auto_increment => 1 }, | ||
| 14 | name => { data_type => 'varchar', size => 100, is_nullable => 0 }, | ||
| 15 | ); | ||
| 16 | 4 | __PACKAGE__->set_primary_key('id'); | |
| 17 | 4 | __PACKAGE__->resultset_class('DBIO::Test::MooSchema::ResultSet::Artist'); | |
| 18 | |||
| 19 | 4 | __PACKAGE__->has_many( | |
| 20 | cds => 'DBIO::Test::MooSchema::Result::CD', 'artist_id' | ||
| 21 | ); | ||
| 22 | |||
| 23 | # Lazy Moo attribute — computed from column data on first access | ||
| 24 | 4 | has display_name => ( is => 'lazy' ); | |
| 25 | 1 | ▶ | sub _build_display_name { 'Artist: ' . $_[0]->name } |
|
Subroutine
_build_display_name: called CC=1 SCAR=0.0
| |||
| 26 | |||
| 27 | # Moo rw attribute with a lazy default (must be lazy — inflate_result bypasses new()) | ||
| 28 | 1 | ▶ | has score => ( is => 'rw', lazy => 1, default => sub { 0 } ); |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 29 | |||
| 30 | 4 | 1; | |
| 31 | |||
| 32 | __END__ | ||