Bugzilla – Attachment 54272 Details for
Bug 17091
Add AUTOLOAD to Koha::Objects
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF]Bug 17091: Add AUTOLOAD to Koha::Objects
SIGNED-OFFBug-17091-Add-AUTOLOAD-to-KohaObjects.patch (text/plain), 1.59 KB, created by
Héctor Eduardo Castro Avalos
on 2016-08-10 14:43:22 UTC
(
hide
)
Description:
[SIGNED-OFF]Bug 17091: Add AUTOLOAD to Koha::Objects
Filename:
MIME Type:
Creator:
Héctor Eduardo Castro Avalos
Created:
2016-08-10 14:43:22 UTC
Size:
1.59 KB
patch
obsolete
>From f581abe04ce3cefaa7007bbb5b244521701136f1 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 9 Aug 2016 15:46:11 +0100 >Subject: [PATCH] [SIGNED-OFF]Bug 17091: Add AUTOLOAD to Koha::Objects > >Up to now if a Koha::Objects based object needs to call DBIx::Class methods, we >have to create a new method for Koha::Objects, something like: > sub method { > my $self = shift; > return $self->_resultset->method > } > >To simplify and ease the call to DBIx::Class method, this patch defines an >AUTOLOAD to call the DBIx::Class method on the resultset we are encapsulating. > >Signed-off-by: Hector Castro <hector.hecaxmmx@gmail.com> >--- > Koha/Objects.pm | 22 ++++++++++++++++++++++ > 1 file changed, 22 insertions(+) > >diff --git a/Koha/Objects.pm b/Koha/Objects.pm >index 97436ad..03f39dc 100644 >--- a/Koha/Objects.pm >+++ b/Koha/Objects.pm >@@ -280,7 +280,29 @@ sub columns { > return Koha::Database->new->schema->resultset( $class->_type )->result_source->columns; > } > >+=head3 AUTOLOAD > >+The autoload method is used call DBIx::Class method on a resultset. >+ >+Important: If you plan to use one of the DBIx::Class methods you must provide >+relevant tests in t/db_dependent/Koha/Objects.t >+Currently count, pager, reset and update are covered. >+ >+=cut >+ >+sub AUTOLOAD { >+ my ( $self, @params ) = @_; >+ >+ my $method = our $AUTOLOAD; >+ $method =~ s/.*:://; >+ >+ my $r = eval { $self->_resultset->$method(@params) }; >+ if ( $@ ) { >+ carp "No method $method found for " . ref($self) . " " . $@; >+ return >+ } >+ return $r; >+} > > =head3 _type > >-- >1.7.10.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 17091
:
54217
|
54218
|
54219
|
54220
|
54221
|
54223
|
54272
|
54273
|
54274
|
54275
|
54276
|
54277
|
55378
|
56142
|
56143
|
56144
|
56145
|
56146
|
56147
|
56148