in reply to Re: Catalyst Models Definitive Guide
in thread Catalyst Models Definitive Guide

Looks like you can just cut and paste the code if you follow the accompanying instructions to set things up. You might get a reply from the author though for an alternative repository.

Feel free to take a stab at it and come back with questions if it’s not working.

Sidenote: I would recommend against–

use base 'DBIx::Class::ResultSet'; sub listall { my $self = shift; my @people = $self->all(); return \@people; }

Well-behaved resultsets should only return the same because they are expected to be chainable and ->all is kind of weirdly redundant so might lead to misunderstandings or over-elaboration of what could be more simple code.

Replies are listed 'Best First'.
Re^3: Catalyst Models Definitive Guide
by mkchris (Sexton) on Jan 21, 2022 at 12:03 UTC
    Thank you, yes I have generally avoided doing ->all in a resultset method for the same reason; also because I may want to return a resultset rather than an array, so if I want an array I can either call it in array context: @people = $c->model("DB::People")->listall or chain $c->model("DB::People")->listall->all.