Skip to content
Browse files

Make named arguments work.

  • Loading branch information...
1 parent e354f39 commit 0583f325095a56a6f8b38ed39d4872411de7148c @rafl committed Oct 12, 2008
Showing with 12 additions and 1 deletion.
  1. +12 −1 lib/MooseX/Method/Signatures.pm
View
13 lib/MooseX/Method/Signatures.pm
@@ -147,7 +147,7 @@ sub make_proto_unwrap {
}
my ($vars, $param_spec) = parse_proto($proto);
- my $inject = "my (${vars}) = MooseX::Meta::Signature::Combined->new(${param_spec})->validate(\@_);";
+ my $inject = "my (${vars}) = MooseX::Method::Signatures::validate(\\\@_, ${param_spec});";
return $inject;
}
@@ -241,6 +241,17 @@ sub inject_scope {
});
}
+sub validate {
+ my ($args, @param_spec) = @_;
+
+ my @named = grep { !ref $_ } @param_spec;
+ my @ret = MooseX::Meta::Signature::Combined->new(@param_spec)->validate(@{ $args });
+ return @ret unless @named;
+
+ my $named_vals = pop @ret;
+ return (@ret, map { $named_vals->{$_} } @named);
+}
+
1;
__END__

0 comments on commit 0583f32

Please sign in to comment.
Something went wrong with that request. Please try again.