DBIx::...ss::Tee(3pm)
π NAME π
DBIx::Class::Helper::ResultClass::Tee β ok so bestie, this one inflates to multiple result classes at the same time. Yes, at the SAME time. Iconic behavior honestly.
We're in the User Contributed Perl Documentation zone, section (3pm), and the page itself is abbreviated down to DBIx::...ss::Tee(3pm) which is giving "we ran out of room on the header line" energy but slay, we move.
β¨ SYNOPSIS β¨
my ($hashref, $obj) = $rs->search(undef, {
result_class => DBIx::Class::Helper::ResultClass::Tee->new(
inner_classes => [ '::HRI', 'MyApp::Schema::Result::User'],
),
})->first->@*;
(If you've never seen ->@* before, go check out "Postfix-Dereference-Syntax" in perlref β it got added in Perl v5.20!) Like it's genuinely that new, no cap.
π¦ DESCRIPTION π¦
So this result class has one obvious use case: you've got prefetched data, and DBIx::Class::ResultClass::HashRefInflator is the simplest way to get at all of it, but you <em>also</em> still wanna use some of the methods sitting on your existing result class. And you're like... why not both? π«Ά
The other big raison d'Γͺtre of this module β and honestly this is the part I'm obsessed with β is that it's a whole example of how to make a "parameterized" result class. Because it's lowkey almost a secret that DBIx::Class supports using objects to inflate results. Bestie. That is an incredibly powerful feature and you can use it to build consistent interfaces that do literally all kinds of things. Main character energy for a result class, fr fr.
Storytime π
: once when I was at Micro Technology Services, Inc., I used this to efficiently do a "reverse synthetic, LIKE-ish join". The "relationship" was basically foreign.name =~ self.name β which cannot actually be done if you wanna go from inside the database. But if you're able to load the entire foreign table into memory, you can do it on-demand instead, and cache it right there in the result class for (in our case) the duration of a request. Chef's kiss. π
π AUTHOR π
Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2024 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
k bye ily, this page was generated by perl v5.40.0 on 2024-11-16, and the manual is the DBIx::...ss::Tee(3pm) one π§β¨
π¦ where this page comes from
- debian trixie: libdbix-class-helpers-perl 2.037000-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libdbix-class-helpers-perl 2.037000-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libdbix-class-helpers-perl 2.037000-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms