Subject: | Why does responseData->results return a list? |
Date: | Mon, 29 Dec 2008 16:58:56 -0600 |
To: | bug-REST-Google [...] rt.cpan.org |
From: | Dave Wolfe <Dave [...] WolfeWorks.net> |
While using REST::Google::Search with Template Toolkit in Catalyst, I
discovered that the responseData->results accessor returns a list of
the (blessed) results instead of a reference to an array of (blessed)
results. I consider this a bug since it makes it impossible to do
something like:
$res->responseData->results->[0]->{url}
Turning an array reference into a list is easy, e.g.:
@{$res->responseData->results}
but turning the list into an array reference in, for example, TT is
impossible. If I try to get the number of results in a template via the
vmethod size, for example:
response.results.size
I always get the number of elements in the first 'results' hash (only
the auto-promotion of the hash to a list prevents it failing with an
error).
The results accessor should do something like the following (note the
encapsulating square brackets to create an anonymous array as the return
value:
return [ map {...} @{...} ];
--
Dave Wolfe