« blib/lib/DBIO/Test/MooseSugarSchema/Result/Artist.pm
↑ Summary
blib/lib/DBIO/Test/Namespace/OtherRslt/D.pm »
| 1 | package DBIO::Test::MooseSugarSchema::Result::CD; | ||
| 2 | # ABSTRACT: Moose + Cake test result class for the cd table (no custom ResultSet) | ||
| 3 | |||
| 4 | our $VERSION = '0.900007'; | ||
| 5 | |||
| 6 | 2 | ▶ | use DBIO::Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | use DBIO::Cake; | ||
| 8 | |||
| 9 | table 'cd'; | ||
| 10 | |||
| 11 | col id => integer auto_inc; | ||
| 12 | col artist_id => integer; | ||
| 13 | col title => varchar(100); | ||
| 14 | col year => integer null; | ||
| 15 | |||
| 16 | primary_key 'id'; | ||
| 17 | |||
| 18 | __PACKAGE__->belongs_to( artist => 'DBIO::Test::MooseSugarSchema::Result::Artist', 'artist_id' ); | ||
| 19 | |||
| 20 | has full_title => ( | ||
| 21 | is => 'ro', | ||
| 22 | isa => 'Str', | ||
| 23 | lazy => 1, | ||
| 24 | builder => '_build_full_title', | ||
| 25 | ); | ||
| 26 | sub _build_full_title { | ||
| 27 | my $self = shift; | ||
| 28 | my $year = $self->year // '?'; | ||
| 29 | sprintf '%s (%s)', $self->title, $year; | ||
| 30 | } | ||
| 31 | |||
| 32 | has rating => ( is => 'rw', isa => 'Int', lazy => 1, default => 0 ); | ||
| 33 | |||
| 34 | __PACKAGE__->meta->make_immutable; | ||
| 35 | |||
| 36 | 1; | ||
| 37 | |||
| 38 | __END__ | ||