Commit | Line | Data |
b51d39c8 |
1 | package DBICTest::Schema::ResultSet::Artist; |
2 | |
3 | use Moose; |
79b18b81 |
4 | use Method::Signatures::Simple; |
b51d39c8 |
5 | extends 'DBICTest::Schema::ResultSet'; |
6 | |
b9495a50 |
7 | method with_substr_multi () { |
8 | $self->_with_meta_hash( |
9 | sub { |
f1690863 |
10 | my $row = shift; |
11 | my $substr = substr($row->{name}, 0, 3); |
b9495a50 |
12 | my $substr2 = substr($row->{name}, 0, 4); |
f1690863 |
13 | $row->{substr} = $substr; |
b9495a50 |
14 | $row->{substr2} = $substr2; |
f1690863 |
15 | return $row; |
16 | } |
17 | ); |
18 | return $self; |
19 | } |
20 | |
b9495a50 |
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 | |
4d83e732 |
30 | method with_substr_key_obj () { |
31 | $self->_with_meta_key( |
32 | substr => sub { |
33 | my ($hash, $obj) = @_; |
34 | return substr($obj->name, 0, 3); |
35 | } |
36 | ); |
37 | return $self; |
38 | } |
39 | |
f1690863 |
40 | method with_substr_old () { |
41 | foreach my $row ($self->all) { |
42 | my $substr = substr($row->name, 0, 3); |
43 | $self->add_row_info(row => $row, info => { substr => $substr }); |
44 | } |
45 | return $self; |
46845551 |
46 | } |
47 | |
b51d39c8 |
48 | 1; |