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

(-)a/Koha/Objects.pm (+15 lines)
Lines 320-325 sub to_api { Link Here
320
    return [ map { $_->to_api } $self->as_list ];
320
    return [ map { $_->to_api } $self->as_list ];
321
}
321
}
322
322
323
=head3 attributes_from_api
324
325
    my $attributes = $objects->attributes_from_api( $api_attributes );
326
327
Translates attributes from the API to DBIC
328
329
=cut
330
331
sub attributes_from_api {
332
    my ( $self, $attributes ) = @_;
333
334
    $self->{_singular_object} ||= $self->object_class->new();
335
    return $self->{_singular_object}->attributes_from_api( $attributes );
336
}
337
323
=head3 Koha::Objects->_wrap
338
=head3 Koha::Objects->_wrap
324
339
325
wraps the DBIC object in a corresponding Koha object
340
wraps the DBIC object in a corresponding Koha object
(-)a/t/db_dependent/Koha/Objects.t (-1 / +22 lines)
Lines 675-677 subtest 'Return same values as DBIx::Class' => sub { Link Here
675
675
676
    };
676
    };
677
};
677
};
678
- 
678
679
subtest "attributes_from_api() tests" => sub {
680
681
    plan tests => 1;
682
683
    $schema->storage->txn_begin;
684
685
    my $cities_rs = Koha::Cities->new;
686
    my $city      = Koha::City->new;
687
688
    my $api_attributes = {
689
        name        => 'Cordoba',
690
        postal_code => 5000
691
    };
692
693
    is_deeply(
694
        $cities_rs->attributes_from_api($api_attributes),
695
        $city->attributes_from_api($api_attributes)
696
    );
697
698
    $schema->storage->txn_rollback;
699
};

Return to bug 24321