From 10bfd0f640825ff111709da65ee0efa6704ab1d0 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Tue, 22 Jun 2010 15:23:50 +0200 Subject: [PATCH] support various $out values This allows us to create datasets from scalars, arrays and hashes --- lib/MojoFacets/Data.pm | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/MojoFacets/Data.pm b/lib/MojoFacets/Data.pm index 9afa1d0..c532142 100644 --- a/lib/MojoFacets/Data.pm +++ b/lib/MojoFacets/Data.pm @@ -656,6 +656,7 @@ sub items { my $commit_dataset = join('.' , $self->param('code_depends') , $self->param('code_description') + , time() ); my $key = $self->param('code_depends'); $key =~ s/,.+$//; @@ -663,7 +664,16 @@ sub items { my $items; foreach my $n ( keys %$out ) { my $i = { $key => [ $n ] }; - $i->{$_} = [ $out->{$n}->{$_} ] foreach keys %{ $out->{$n} }; + my $ref = ref $out->{$n}; + if ( $ref eq 'HASH' ) { + $i->{$_} = [ $out->{$n}->{$_} ] foreach keys %{ $out->{$n} }; + } elsif ( $ref eq 'ARRAY' ) { + $i->{$_} = $out->{$n}; + } elsif ( ! $ref ) { + $i->{value} = [ $out->{$n} ]; + } else { + $i->{_error} = [ dump($out->{$n}) ]; + } push @$items, $i; }; undef $out; -- 2.20.1