Created
July 11, 2011 19:32
-
-
Save brianjmiller/1076600 to your computer and use it in GitHub Desktop.
make_itl_loop_struct
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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