expand DispatchNode comment
[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
67a6b9da 9# this ensures that the dispatchers get called as methods of the app itself
b6863c58 10# and if the first argument is a hashref, localizes %_ to it to permit
11# use of $_{name} inside the dispatch sub
4ed4fb42 12around _curry => sub {
13 my ($orig, $self) = (shift, shift);
bfa34345 14 my $code = $self->$orig($self->_app_object, @_);
15 ref($_[0]) eq 'HASH'
16 ? do { my $v = $_[0]; sub { local *_ = $v; &$code } }
17 : $code
4ed4fb42 18};
19
201;