Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re^2: Catalyst Models Definitive Guide

by Your Mother (Archbishop)
on Jan 20, 2022 at 12:46 UTC ( #11140644=note: print w/replies, xml ) Need Help??

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.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11140644]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2022-05-24 19:23 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (84 votes). Check out past polls.