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 | |
fbe6d90c |
21 | method with_substr_multi_object () { |
22 | $self->_with_object_meta_hash( |
23 | sub { |
24 | my ($row_hash, $row_object) = @_; |
25 | my $substr = substr($row_object->name, 0, 3); |
26 | my $substr2 = substr($row_object->name, 0, 4); |
27 | my $row = { |
28 | substr => $substr, |
29 | substr2 => $substr2, |
30 | }; |
31 | return $row; |
32 | } |
33 | ); |
34 | return $self; |
35 | } |
36 | |
b9495a50 |
37 | method with_substr_key () { |
38 | $self->_with_meta_key( |
39 | substr => sub { |
40 | return substr(shift->{name}, 0, 3); |
41 | } |
42 | ); |
43 | return $self; |
44 | } |
45 | |
4d83e732 |
46 | method with_substr_key_obj () { |
9432d8bf |
47 | $self->_with_object_meta_key( |
4d83e732 |
48 | substr => sub { |
49 | my ($hash, $obj) = @_; |
50 | return substr($obj->name, 0, 3); |
51 | } |
52 | ); |
53 | return $self; |
54 | } |
55 | |
f1690863 |
56 | method with_substr_old () { |
57 | foreach my $row ($self->all) { |
58 | my $substr = substr($row->name, 0, 3); |
59 | $self->add_row_info(row => $row, info => { substr => $substr }); |
60 | } |
61 | return $self; |
46845551 |
62 | } |
63 | |
b51d39c8 |
64 | 1; |