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 672-674 subtest 'Return same values as DBIx::Class' => sub { Link Here
672
672
673
    };
673
    };
674
};
674
};
675
- 
675
676
subtest "attributes_from_api() tests" => sub {
677
678
    plan tests => 1;
679
680
    $schema->storage->txn_begin;
681
682
    my $cities_rs = Koha::Cities->new;
683
    my $city      = Koha::City->new;
684
685
    my $api_attributes = {
686
        name        => 'Cordoba',
687
        postal_code => 5000
688
    };
689
690
    is_deeply(
691
        $cities_rs->attributes_from_api($api_attributes),
692
        $city->attributes_from_api($api_attributes)
693
    );
694
695
    $schema->storage->txn_rollback;
696
};

Return to bug 24321