GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
DBIx::Class::Helper::ResultClass::Tee(3) User Contributed Perl Documentation DBIx::Class::Helper::ResultClass::Tee(3)

DBIx::Class::Helper::ResultClass::Tee - Inflate to multiple result classes at the same time

   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, check out "Postfix-Dereference-Syntax" in perlref, added in Perl v5.20!)

This result class has one obvious use case: when you have prefetched data and DBIx::Class::ResultClass::HashRefInflator is the simplest way to access all the data, but you still want to use some of the methods on your existing result class.

The other important raison d'être of this module is that it is an example of how to make a "parameterized" result class. It's almost a secret that DBIx::Class supports using objects to inflate results. This is an incredibly powerful feature that can be used to make consistent interfaces to do all kinds of things.

Once when I was at Micro Technology Services, Inc. I used it to efficiently do a "reverse synthetic, LIKE-ish join". The "relationship" was basically "foreign.name =~ self.name", which cannot actually be done if you want to go from within the database, but if you are able to load the entire foreign table into memory this can be done on-demand, and cached within the result class for (in our case) the duration of a request.

Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>

This software is copyright (c) 2020 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.

2020-03-28 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.