$dq->{type} and $dq->{type} eq $name
};
push @EXPORT, $sub;
- if ($map{$name}) {
- my @map = @{$map{$name}};
+ if (my @map = @{$map{$name}||[]}) {
*$name = sub {
my $dq = { type => $name };
- foreach (0..$#_) {
+ foreach (0..$#map) {
$dq->{$map[$_]} = $_[$_] if defined $_[$_];
}
+
+ if (my $optional = $_[$#map+1]) {
+ unless(ref $optional eq 'HASH') {
+ require Carp;
+ Carp::croak("Not a hashreference");
+ }
+ @{$dq}{keys %$optional} = values %$optional;
+ }
+
return $dq;
};
push @EXPORT, $name;