Skip to content

Commit

Permalink
fix single-value case for expected arrayref (GH#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
mickeyn committed May 12, 2017
1 parent 03011f9 commit 6f1f80e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/MetaCPAN/Client/Role/Entity.pm
Expand Up @@ -42,6 +42,12 @@ sub BUILDARGS {
}

for my $k ( @{ $known_fields->{arrayref} } ) {
# fix the case when we expect an array ref but get a scalar because
# the result array had one element and we received a scalar
if ( defined($args{data}{$k}) and !is_ref($args{data}{$k}) ) {
$args{data}{$k} = [ $args{data}{$k} ]
}

delete $args{data}{$k}
unless is_arrayref( $args{data}{$k} ); # warn?
}
Expand Down

0 comments on commit 6f1f80e

Please sign in to comment.