1 package CatalystX::UriFor::Curried;
2 use MooseX::Role::Parameterized;
4 use MooseX::Types::Moose qw/ Str ArrayRef /;
5 use Scalar::Util qw/ weaken /;
6 use namespace::autoclean;
8 parameter method_name => (
13 parameter stash_captures => (
21 my $method_name = $p->method_name;
22 my $stash_captures => $p->stash_captures;
24 method $method_name => sub {
25 my ($ctx, $action_or_private_path, $captures, @args) = @_;
26 my $weak_ctx = $ctx; # Just for safety so it can't be closed over.
28 my $params = ref($args[-1]) eq 'HASH' ? pop(@args) : {};
29 if (ref($captures) eq 'ARRAY' || (!$captures && !scalar(@args))) { # FIXME BUG IN THIS LOGIC
31 foreach my $name_or_sub ($stash_captures->flatten) {
32 unshift(@$captures, ref($name_or_sub) eq 'CODE' ? $name_or_sub->($weak_ctx) : $ctx->stash->{$name_or_sub});
34 $ctx->uri_for_action($action_or_private_path, $captures, @args, $params);
44 CatalystX::UriFor::Curried -
54 =head1 COPYRIGHT & LICENSE
56 Copyright 2009 the above author(s).
58 This sofware is free software, and is licensed under the same terms as perl itself.