From d792583186d4942a8b80d0f281afd91b64f91a95 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 10 Feb 2015 13:30:32 -0500 Subject: [PATCH] Bug 13019 [QA Followup] - Allow chaining By returning the object itself instead of a boolean, we can chain methods together while retaining the exact same functionality. Signed-off-by: Tomas Cohen Arazi --- Koha/Object.pm | 4 ++-- Koha/Objects.pm | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Koha/Object.pm b/Koha/Object.pm index bc2746fcdd..a77eb5cfe0 100644 --- a/Koha/Object.pm +++ b/Koha/Object.pm @@ -106,7 +106,7 @@ Returns: sub store { my ($self) = @_; - return $self->_result()->update_or_insert() ? 1 : 0; + return $self->_result()->update_or_insert() ? $self : undef; } =head3 $object->in_storage(); @@ -190,7 +190,7 @@ sub set { } } - return $self->_result()->set_columns($properties) ? 1 : undef; + return $self->_result()->set_columns($properties) ? $self : undef; } =head3 $object->id(); diff --git a/Koha/Objects.pm b/Koha/Objects.pm index 5413fb635e..6b3100a678 100644 --- a/Koha/Objects.pm +++ b/Koha/Objects.pm @@ -80,6 +80,8 @@ my $object = Koha::Objects->find( { keypart1 => $keypart1, keypart2 => $keypart2 sub find { my ( $self, $id ) = @_; + return unless $id; + my $result = $self->_resultset()->find($id); my $object = $self->object_class()->_new_from_dbic( $result ); -- 2.11.0