Skip to content

Instantly share code, notes, and snippets.

@brianjmiller
Created July 11, 2011 19:32
Show Gist options
  • Save brianjmiller/1076600 to your computer and use it in GitHub Desktop.
Save brianjmiller/1076600 to your computer and use it in GitHub Desktop.
make_itl_loop_struct
#
# given an array of hash refs return a structure that is designed to used
# by one of IC's looping tags via the "list" attribute
#
sub make_itl_loop_struct {
my $self = shift;
my $data = shift;
unless (defined $data) {
Vend::Exception::ArgumentMissing->throw('data arg not provided');
}
unless (ref $data eq 'ARRAY') {
Vend::Exception->throw('Invalid type of data arg: not an array ref');
}
for my $element (@$data) {
next if ref $element eq 'HASH';
Vend::Exception->throw('Invalid element of data list: not a hash ref');
}
return [
$data,
undef,
[ keys %{ $data->[0] } ],
];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment