View | Details | Raw Unified | Return to bug 25303
Collapse All | Expand All

(-)a/Koha/Objects.pm (-3 / +24 lines)
Lines 21-26 use Modern::Perl; Link Here
21
21
22
use Carp;
22
use Carp;
23
use List::MoreUtils qw( none );
23
use List::MoreUtils qw( none );
24
use Class::Inspector;
24
25
25
use Koha::Database;
26
use Koha::Database;
26
27
Lines 171-176 sub search_related { Link Here
171
    }
172
    }
172
}
173
}
173
174
175
=head3 delete
176
177
=cut
178
179
sub delete {
180
    my ($self) = @_;
181
182
    if ( Class::Inspector->function_exists( $self->object_class, 'delete' ) ) {
183
        my $objects_deleted;
184
        $self->_resultset->result_source->schema->txn_do( sub {
185
            while ( my $o = $self->next ) {
186
                $o->delete;
187
                $objects_deleted++;
188
            }
189
        });
190
        return $objects_deleted;
191
    }
192
193
    return $self->_resultset->delete;
194
}
195
174
=head3 single
196
=head3 single
175
197
176
my $object = Koha::Objects->search({}, { rows => 1 })->single
198
my $object = Koha::Objects->search({}, { rows => 1 })->single
Lines 431-444 The autoload method is used call DBIx::Class method on a resultset. Link Here
431
453
432
Important: If you plan to use one of the DBIx::Class methods you must provide
454
Important: If you plan to use one of the DBIx::Class methods you must provide
433
relevant tests in t/db_dependent/Koha/Objects.t
455
relevant tests in t/db_dependent/Koha/Objects.t
434
Currently count, pager, update and delete are covered.
456
Currently count, is_paged, pager, update, result_class, single and slice are covered.
435
457
436
=cut
458
=cut
437
459
438
sub AUTOLOAD {
460
sub AUTOLOAD {
439
    my ( $self, @params ) = @_;
461
    my ( $self, @params ) = @_;
440
462
441
    my @known_methods = qw( count is_paged pager update delete result_class single slice );
463
    my @known_methods = qw( count is_paged pager update result_class single slice );
442
    my $method = our $AUTOLOAD;
464
    my $method = our $AUTOLOAD;
443
    $method =~ s/.*:://;
465
    $method =~ s/.*:://;
444
466
445
- 

Return to bug 25303