From d4c092c9ee39eb9ce5955350cc8d97ff42a3699d 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. --- 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 bc2746f..a77eb5c 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 5413fb6..6b3100a 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 ); -- 1.7.2.5