stick DispatchNode comments to the appropiate code
[catagits/Web-Simple.git] / lib / Web / Simple / DispatchNode.pm
CommitLineData
4ed4fb42 1package Web::Simple::DispatchNode;
2
3use Moo;
4
5extends 'Web::Dispatch::Node';
6
7has _app_object => (is => 'ro', init_arg => 'app_object', required => 1);
8
9around _curry => sub {
10 my ($orig, $self) = (shift, shift);
d20b763a 11 # this ensures that the dispatchers get called as methods of the app itself
bfa34345 12 my $code = $self->$orig($self->_app_object, @_);
d20b763a 13 # if the first argument is a hashref, localize %_ to it to permit
14 # use of $_{name} inside the dispatch sub
bfa34345 15 ref($_[0]) eq 'HASH'
16 ? do { my $v = $_[0]; sub { local *_ = $v; &$code } }
17 : $code
4ed4fb42 18};
19
201;