.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "DBIx::Class::Helper::Row::ProxyResultSetMethod 3pm" .TH DBIx::Class::Helper::Row::ProxyResultSetMethod 3pm "2022-12-06" "perl v5.36.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" DBIx::Class::Helper::Row::ProxyResultSetMethod \- Efficiently reuse ResultSet methods from results with fallback .SH "SYNOPSIS" .IX Header "SYNOPSIS" ResultSet: .PP .Vb 1 \& package MyApp::Schema::ResultSet::Foo; \& \& use parent \*(AqDBIx::Class::ResultSet\*(Aq; \& \& _\|_PACKAGE_\|_\->load_components(qw( \& Helper::ResultSet::CorrelateRelationship \& )); \& \& ...; \& \& sub with_friend_count { \& shift\->search(undef, { \& \*(Aq+columns\*(Aq => { \& \*(Aqfriend_count\*(Aq => $self\->correlate(\*(Aqfriends\*(Aq)\->count_rs\->as_query, \& }, \& }) \& } .Ve .PP Result: .PP .Vb 1 \& package MyApp::Schema::Result::Foo; \& \& use parent \*(AqDBIx::Class::Core\*(Aq; \& \& _\|_PACKAGE_\|_\->load_components(qw( Helper::Row::ProxyResultSetMethod )); \& \& _\|_PACKAGE_\|_\->proxy_resultset_method(\*(Aqfriend_count\*(Aq); .Ve .PP or with DBIx::Class::Candy: .PP .Vb 1 \& package MyApp::Schema::Result::Foo; \& \& use DBIx::Class::Candy \-components => [\*(AqHelper::Row::ProxyResultSetMethod\*(Aq]; \& \& proxy_resultset_method \*(Aqfriend_count\*(Aq; .Ve .PP Elsewhere: .PP .Vb 2 \& my $row = $foo_rs\->first; \& say $row\->friend_count . \*(Aq friends\*(Aq; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module makes reusing resultset methods from a result trivially easy. You should be using it. .SH "METHODS" .IX Header "METHODS" .SS "proxy_resultset_method" .IX Subsection "proxy_resultset_method" .Vb 4 \& _\|_PACKAGE_\|_\->proxy_resultset_method( $name => { \& slot => $slot, \& resultset_method => $rs_method \& }); .Ve .PP \&\f(CW\*(C`proxy_resultset_method\*(C'\fR's first argument is the name of the method to generate and is required. The other two arguments, \f(CW$slot\fR, and \&\f(CW$resultset_method\fR are optional. If unspecified \f(CW$slot\fR will default to \&\f(CW$name\fR and \f(CW$resultset_method\fR will default to \f(CW"with_$name"\fR. \f(CW$slot\fR is the column that the data being retrieved is stored as in the ResultSet method being proxied to. \f(CW$resultset_method\fR is (duh) the ResultSet method being proxied to. .PP If you did not call the \f(CW\*(C`with_*\*(C'\fR method on your ResultSet, and call the proxy method, it will transparently \fBfallback\fR and do the call and fetch the needed data. E.g.: .PP .Vb 2 \& my $foo = $schema\->resultset(\*(AqFoo\*(Aq)\->first; ## did not call with_friend_count \& print $foo\->friend_count; ## will produce desired result magically .Ve .SH "CANDY EXPORTS" .IX Header "CANDY EXPORTS" If used in conjunction with DBIx::Class::Candy this component will export: .IP "proxy_resultset_method" 4 .IX Item "proxy_resultset_method" .SH "DEDICATION" .IX Header "DEDICATION" This module is dedicated to Ray Bradbury, who wrote Something Wicked This Way Comes, Dandelion Wine, and numerous short stories, plays, etc etc. Read this author's books. .SH "AUTHOR" .IX Header "AUTHOR" Arthur Axel \*(L"fREW\*(R" Schmidt .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2020 by Arthur Axel \*(L"fREW\*(R" Schmidt. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.