a3688f25c9e13aa37bfc19f985faa4b5d7048d75
[dbsrgits/DBIx-Class-ResultSet-WithMetaData.git] / t / lib / DBICTest / Schema / ResultSet / Artist.pm
1 package DBICTest::Schema::ResultSet::Artist;
2
3 use Moose;
4 use Method::Signatures::Simple;
5 extends 'DBICTest::Schema::ResultSet';
6
7 method with_substr_multi () {
8   $self->_with_meta_hash( 
9     sub {
10       my $row = shift;
11       my $substr = substr($row->{name}, 0, 3);
12       my $substr2 = substr($row->{name}, 0, 4);
13       $row->{substr} = $substr;
14       $row->{substr2} = $substr2;
15       return $row;
16     }
17   );
18   return $self;
19 }
20
21 method with_substr_key () {
22   $self->_with_meta_key( 
23     substr => sub {
24       return substr(shift->{name}, 0, 3);
25     }
26   );
27   return $self;
28 }
29
30 method with_substr_old () {
31   foreach my $row ($self->all) {
32     my $substr = substr($row->name, 0, 3);
33     $self->add_row_info(row => $row, info => { substr => $substr });
34   }
35   return $self;
36 }
37
38 1;