scalar data are ids
This commit is contained in:
parent
8639858b60
commit
5dd5e664e9
@ -85,6 +85,9 @@ sub serialize_data ( $self, $data, $extra_data = {}, $included = undef ) {
|
||||
|
||||
return [ map { $self->serialize_data($_,$extra_data, $included) } @$data ] if ref $data eq 'ARRAY';
|
||||
|
||||
# it's a scalar? it's the id
|
||||
return { id => $data, type => $self->type } unless ref $data;
|
||||
|
||||
my $s = {
|
||||
type => $self->type,
|
||||
id => $self->gen_id($data) };
|
||||
|
@ -66,6 +66,16 @@ subtest 'attributes' => sub {
|
||||
|
||||
};
|
||||
|
||||
subtest 'a single scalar == id', sub {
|
||||
my $serialized =
|
||||
Dancer2::Plugin::JsonApi::Registry::Schema->new( type => 'thing' )
|
||||
->serialize('blah');
|
||||
|
||||
is $serialized->{data} => {
|
||||
type => 'thing',
|
||||
id => 'blah',
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
done_testing();
|
||||
|
Loading…
Reference in New Issue
Block a user