X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FWeb%2FSimple%2FDispatchNode.pm;h=f3b0e5682b8a23df33b220203402ed81cce9b406;hb=d20b763a1ce47f0bcbe7facf56cec232ece7533f;hp=36e5e6760cc8d9661e2ac523ed4276693af79624;hpb=67a6b9da784f1245688796c26d2da5b9a4c8962c;p=catagits%2FWeb-Simple.git diff --git a/lib/Web/Simple/DispatchNode.pm b/lib/Web/Simple/DispatchNode.pm index 36e5e67..f3b0e56 100644 --- a/lib/Web/Simple/DispatchNode.pm +++ b/lib/Web/Simple/DispatchNode.pm @@ -6,10 +6,15 @@ extends 'Web::Dispatch::Node'; has _app_object => (is => 'ro', init_arg => 'app_object', required => 1); -# this ensures that the dispatchers get called as methods of the app itself around _curry => sub { my ($orig, $self) = (shift, shift); - $self->$orig($self->_app_object, @_); + # this ensures that the dispatchers get called as methods of the app itself + my $code = $self->$orig($self->_app_object, @_); + # if the first argument is a hashref, localize %_ to it to permit + # use of $_{name} inside the dispatch sub + ref($_[0]) eq 'HASH' + ? do { my $v = $_[0]; sub { local *_ = $v; &$code } } + : $code }; 1;