Bugzilla – Attachment 35985 Details for
Bug 13719
Make Koha::Objects store list of resultant objects on an as needed basis
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 13719 - Store list of objects as needed
Bug-13719---Store-list-of-objects-as-needed.patch (text/plain), 2.52 KB, created by
Kyle M Hall
on 2015-02-17 18:34:31 UTC
(
hide
)
Description:
Bug 13719 - Store list of objects as needed
Filename:
MIME Type:
Creator:
Kyle M Hall
Created:
2015-02-17 18:34:31 UTC
Size:
2.52 KB
patch
obsolete
>From 2e63f39e7c04d28e8989b13bd4bed82531680542 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Tue, 17 Feb 2015 10:10:28 -0500 >Subject: [PATCH] Bug 13719 - Store list of objects as needed > >--- > Koha/Objects.pm | 38 ++++++++++++++++++++++++-------------- > 1 files changed, 24 insertions(+), 14 deletions(-) > >diff --git a/Koha/Objects.pm b/Koha/Objects.pm >index a364d25..8a3edad 100644 >--- a/Koha/Objects.pm >+++ b/Koha/Objects.pm >@@ -54,6 +54,8 @@ sub new { > my ($class) = @_; > my $self = {}; > >+ $self->{_iterator} = 0; >+ > bless( $self, $class ); > } > >@@ -67,6 +69,8 @@ sub _new_from_dbic { > my ( $class, $resultset ) = @_; > my $self = { _resultset => $resultset }; > >+ $self->{_iterator} = 0; >+ > bless( $self, $class ); > } > >@@ -138,10 +142,9 @@ Returns undef if there are no more objects to return. > sub next { > my ( $self ) = @_; > >- my $result = $self->_resultset()->next(); >- return unless $result; >+ my $object = $self->_objects()->[ $self->{_iterator}++ ]; > >- my $object = $self->object_class()->_new_from_dbic( $result ); >+ $self->reset() unless $object; > > return $object; > } >@@ -157,12 +160,7 @@ Returns the first object that is part of this set. > sub first { > my ( $self ) = @_; > >- my $result = $self->_resultset()->first(); >- return unless $result; >- >- my $object = $self->object_class()->_new_from_dbic( $result ); >- >- return $object; >+ return $self->_objects()->[0]; > } > > =head3 Koha::Objects->reset(); >@@ -177,7 +175,7 @@ with the first object in a set. > sub reset { > my ( $self ) = @_; > >- $self->_resultset()->reset(); >+ $self->{_iterator} = 0; > > return $self; > } >@@ -193,11 +191,23 @@ Returns an arrayref of the objects in this set. > sub as_list { > my ( $self ) = @_; > >- my @dbic_rows = $self->_resultset()->all(); >+ my $objects = $self->_objects(); >+ >+ return wantarray ? @$objects : $objects; >+} >+ >+=head3 Koha::Objects->_objects >+ >+Returns an arrayref of all the objects that are part of this Objects set >+ >+=cut >+ >+sub _objects { >+ my ( $self ) = @_; > >- my @objects = $self->_wrap(@dbic_rows); >+ $self->{_objects} ||= $self->_wrap( $self->_resultset()->all() ); > >- return wantarray ? @objects : \@objects; >+ return $self->{_objects}; > } > > =head3 Koha::Objects->_wrap >@@ -211,7 +221,7 @@ sub _wrap { > > my @objects = map { $self->object_class()->_new_from_dbic( $_ ) } @dbic_rows; > >- return @objects; >+ return wantarray ? @objects : \@objects;; > } > > =head3 Koha::Objects->_resultset >-- >1.7.2.5
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 13719
:
35985
|
36022
|
45862