From 544bfba037c2056a153677814a77071327edf83a Mon Sep 17 00:00:00 2001 From: Marco Fontani Date: Mon, 6 Sep 2010 20:58:47 +0100 Subject: [PATCH] Map buckets if there are any --- lib/Google/Storage.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/Google/Storage.pm b/lib/Google/Storage.pm index 469b770..a2438d6 100644 --- a/lib/Google/Storage.pm +++ b/lib/Google/Storage.pm @@ -71,10 +71,12 @@ method buckets { my $parse_tree = XML::Bare->new(text=>$response->decoded_content); my $parsed_content = $parse_tree->parse; my $buckets = $parsed_content->{ListAllMyBucketsResult}->{Buckets}->{Bucket}; - my @buckets = map { Google::Storage::Bucket->new( + my @buckets; + @buckets = map { Google::Storage::Bucket->new( creation_date => $_->{CreationDate}->{value}, name => $_->{Name}->{value}, - ) } ref $buckets eq 'ARRAY' ? @$buckets : ($buckets); + ) } ref $buckets eq 'ARRAY' ? @$buckets : ($buckets) + if defined $buckets; return { owner_id => $parsed_content->{ListAllMyBucketsResult}->{Owner}->{ID}->{value},