all_from 'lib/DBIx/Class/ResultSet/WithMetaData.pm';
requires 'DBIx::Class' => 0.08100;
-requires 'MooseX::Method::Signatures' => 0.16;
+requires 'Method::Signatures::Simple' => 0.05;
requires 'Data::Alias';
requires 'DBIx::Class::ResultClass::HashRefInflator';
use Data::Alias;
use Moose;
-use MooseX::Method::Signatures;
+use Method::Signatures::Simple;
extends 'DBIx::Class::ResultSet';
has '_row_info' => (
=cut
-method add_row_info (Int :$id, :$row, HashRef :$info) {
+method add_row_info (%opts) {
+ my ($row, $id, $info) = map { $opts{$_} } qw/row id info/;
if ($row) {
$id = $self->_mk_id(row => { $row->get_columns });
}
$self->_row_info->{$id} = $info;
}
-method row_info_for (Int :$id) {
+method row_info_for (%opts) {
+ my $id = $opts{id};
return $self->_row_info->{$id};
}
=cut
-method order_by (Str :$col) {
+method order_by (%opts) {
+ my $col = $opts{col};
$col = "me.$col" unless ($col =~ m/\./);
return $self->search({}, { order_by => $col });
}
=cut
-method limit (Int :$count) {
+method limit (%opts) {
+ my $count = $opts{count};
return $self->search({}, { rows => $count });
}
-method _mk_id (HashRef :$row) {
+method _mk_id (%opts) {
+ my $row = $opts{row};
return join('-', map { $row->{$_} } @{$self->id_cols});
}
], 'display with substring okay');
}
+{
+ my $artists = $schema->resultset('Artist')->order_by(col => 'artistid')->with_substr->search({}, { prefetch => 'cds', rows => 1 })->display();
+ use Data::Dumper; print Dumper($artists); exit;
+ is_deeply($artists, [
+ {
+ 'artistid' => '1',
+ 'name' => 'Caterwauler McCrae',
+ 'substr' => 'Cat'
+ },
+ {
+ 'artistid' => '2',
+ 'name' => 'Random Boy Band',
+ 'substr' => 'Ran'
+ },
+ {
+ 'artistid' => '3',
+ 'name' => 'We Are Goth',
+ 'substr' => 'We '
+ }
+ ], 'display with substring okay');
+}
+