Permalink
Browse files

ensure that rows are extracted from cache contents as well, when want…

…array is in effect
  • Loading branch information...
1 parent 93e2761 commit 3311fcdd31f57dec91740f2a0db1403925ce002f @wchristian wchristian committed Nov 25, 2011
Showing with 8 additions and 7 deletions.
  1. +8 −7 lib/Net/LastFMAPI.pm
View
@@ -211,7 +211,7 @@ sub lastfm {
my $file = "$cache/".md5_hex(encode_json(\@_));
if (-f $file) {
my $data = loadfile($file);
- return $data->{content}
+ return _rowify_content( $data->{content} );
}
else {
$cache = $file
@@ -288,12 +288,13 @@ sub lastfm {
dumpfile($cache, {content => $content});
}
$last_response = $content;
- if (wantarray) {
- return extract_rows($content);
- }
- else {
- return $content;
- }
+ return _rowify_content( $content );
+}
+
+sub _rowify_content {
+ my ( $content ) = @_;
+ return extract_rows( $content ) if wantarray;
+ return $content;
}
sub extract_rows {

0 comments on commit 3311fcd

Please sign in to comment.