Bug 13019: [QA Follow-up] Rename new_from_dbic and few typos
Since new_from_dbic is not meant as a public method, this patch adds a prefix to the name of this internal routine. For the same reason I removed it from t/Borrower.t. Removed one use overload-line in Objects (not used). Resolved a few typos. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
This commit is contained in:
parent
d562df4af2
commit
074428bb8a
3 changed files with 16 additions and 19 deletions
|
@ -69,13 +69,13 @@ sub new {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
=head3 Koha::Object->new_from_dbic();
|
=head3 Koha::Object->_new_from_dbic();
|
||||||
|
|
||||||
my $object = Koha::Object->new_from_dbic($dbic_row);
|
my $object = Koha::Object->_new_from_dbic($dbic_row);
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub new_from_dbic {
|
sub _new_from_dbic {
|
||||||
my ( $class, $dbic_row ) = @_;
|
my ( $class, $dbic_row ) = @_;
|
||||||
my $self = {};
|
my $self = {};
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,6 @@ package Koha::Objects;
|
||||||
# with Koha; if not, write to the Free Software Foundation, Inc.,
|
# with Koha; if not, write to the Free Software Foundation, Inc.,
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
use overload "0+" => "count", "<>" => "next", fallback => 1;
|
|
||||||
|
|
||||||
use Modern::Perl;
|
use Modern::Perl;
|
||||||
|
|
||||||
use Carp;
|
use Carp;
|
||||||
|
@ -59,13 +57,13 @@ sub new {
|
||||||
bless( $self, $class );
|
bless( $self, $class );
|
||||||
}
|
}
|
||||||
|
|
||||||
=head3 Koha::Objects->new_from_dbic();
|
=head3 Koha::Objects->_new_from_dbic();
|
||||||
|
|
||||||
my $object = Koha::Objects->new_from_dbic( $resultset );
|
my $object = Koha::Objects->_new_from_dbic( $resultset );
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub new_from_dbic {
|
sub _new_from_dbic {
|
||||||
my ( $class, $resultset ) = @_;
|
my ( $class, $resultset ) = @_;
|
||||||
my $self = { _resultset => $resultset };
|
my $self = { _resultset => $resultset };
|
||||||
|
|
||||||
|
@ -84,7 +82,7 @@ sub find {
|
||||||
|
|
||||||
my $result = $self->_resultset()->find($id);
|
my $result = $self->_resultset()->find($id);
|
||||||
|
|
||||||
my $object = $self->object_class()->new_from_dbic( $result );
|
my $object = $self->object_class()->_new_from_dbic( $result );
|
||||||
|
|
||||||
return $object;
|
return $object;
|
||||||
}
|
}
|
||||||
|
@ -108,7 +106,7 @@ sub search {
|
||||||
my $class = ref($self) ? ref($self) : $self;
|
my $class = ref($self) ? ref($self) : $self;
|
||||||
my $rs = $self->_resultset()->search($params);
|
my $rs = $self->_resultset()->search($params);
|
||||||
|
|
||||||
return $class->new_from_dbic($rs);
|
return $class->_new_from_dbic($rs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,7 +124,7 @@ sub count {
|
||||||
|
|
||||||
=head3 Koha::Objects->next();
|
=head3 Koha::Objects->next();
|
||||||
|
|
||||||
my $object = Koha::Object->next();
|
my $object = Koha::Objects->next();
|
||||||
|
|
||||||
Returns the next object that is part of this set.
|
Returns the next object that is part of this set.
|
||||||
Returns undef if there are no more objects to return.
|
Returns undef if there are no more objects to return.
|
||||||
|
@ -134,12 +132,12 @@ Returns undef if there are no more objects to return.
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub next {
|
sub next {
|
||||||
my ( $self, $id ) = @_;
|
my ( $self ) = @_;
|
||||||
|
|
||||||
my $result = $self->_resultset()->next();
|
my $result = $self->_resultset()->next();
|
||||||
return unless $result;
|
return unless $result;
|
||||||
|
|
||||||
my $object = $self->object_class()->new_from_dbic( $result );
|
my $object = $self->object_class()->_new_from_dbic( $result );
|
||||||
|
|
||||||
return $object;
|
return $object;
|
||||||
}
|
}
|
||||||
|
@ -154,7 +152,7 @@ with the first object in a set.
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub reset {
|
sub reset {
|
||||||
my ( $self, $id ) = @_;
|
my ( $self ) = @_;
|
||||||
|
|
||||||
$self->_resultset()->reset();
|
$self->_resultset()->reset();
|
||||||
|
|
||||||
|
@ -170,7 +168,7 @@ Returns an arrayref of the objects in this set.
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub as_list {
|
sub as_list {
|
||||||
my ( $self, $id ) = @_;
|
my ( $self ) = @_;
|
||||||
|
|
||||||
my @dbic_rows = $self->_resultset()->all();
|
my @dbic_rows = $self->_resultset()->all();
|
||||||
|
|
||||||
|
@ -181,14 +179,14 @@ sub as_list {
|
||||||
|
|
||||||
=head3 Koha::Objects->_wrap
|
=head3 Koha::Objects->_wrap
|
||||||
|
|
||||||
wraps the DBIC object in a corrosponding Koha object
|
wraps the DBIC object in a corresponding Koha object
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub _wrap {
|
sub _wrap {
|
||||||
my ( $self, @dbic_rows ) = @_;
|
my ( $self, @dbic_rows ) = @_;
|
||||||
|
|
||||||
my @objects = map { $self->object_class()->new_from_dbic( $_ ) } @dbic_rows;
|
my @objects = map { $self->object_class()->_new_from_dbic( $_ ) } @dbic_rows;
|
||||||
|
|
||||||
return @objects;
|
return @objects;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,8 +27,7 @@ BEGIN {
|
||||||
use_ok('Koha::Borrower');
|
use_ok('Koha::Borrower');
|
||||||
}
|
}
|
||||||
|
|
||||||
my $result = Koha::Database->new()->schema()->resultset('Borrower')->new({ surname => 'Test Borrower' });
|
my $object = Koha::Borrower->new( { surname => 'Test Borrower' } );
|
||||||
my $object = Koha::Borrower->new_from_dbic( $result );
|
|
||||||
|
|
||||||
is( $object->surname(), 'Test Borrower', "Accessor returns correct value" );
|
is( $object->surname(), 'Test Borrower', "Accessor returns correct value" );
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue