Skip to content
Snippets Groups Projects
Commit 898fc6cd authored by Anton Soldatov's avatar Anton Soldatov
Browse files

Fixed issues with handling `expect_single_object`

parent 64b8e746
No related branches found
No related tags found
No related merge requests found
...@@ -362,7 +362,8 @@ sub _response ...@@ -362,7 +362,8 @@ sub _response
} }
if ($self->{expect_single_object} && $self->{no_wrapper_object}) { if ($self->{expect_single_object} && $self->{no_wrapper_object}) {
$content = delete $content->{$self->{expect_single_object}}; my @key = grep { !/^(total_count|offset|limit)$/ } keys %$content;
$content = delete $content->{$key[0]} if @key == 1;
} }
return $content; return $content;
...@@ -412,6 +413,8 @@ sub _dispatch_name ...@@ -412,6 +413,8 @@ sub _dispatch_name
$data->{content} = pop @args; $data->{content} = pop @args;
} }
delete $self->{expect_single_object};
$objects = $self->_normalize_objects($objects); $objects = $self->_normalize_objects($objects);
my $i = 0; my $i = 0;
my @objects; my @objects;
...@@ -453,11 +456,9 @@ sub _dispatch_last_object ...@@ -453,11 +456,9 @@ sub _dispatch_last_object
my $object = shift; my $object = shift;
my $data = shift; my $data = shift;
delete $self->{expect_single_object};
if (length $object) { if (length $object) {
if ($action eq 'get' || $action eq 'create') { if ($action eq 'get' || $action eq 'create') {
$self->{expect_single_object} = $object; $self->{expect_single_object} = 1;
} }
if ($self->{no_wrapper_object}) { if ($self->{no_wrapper_object}) {
if ($action eq 'create' || $action eq 'update') { if ($action eq 'create' || $action eq 'update') {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment