File: Node.pm

package info (click to toggle)
libweb-simple-perl 0.016-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 348 kB
  • sloc: perl: 1,588; makefile: 2
file content (26 lines) | stat: -rw-r--r-- 418 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package Web::Dispatch::Node;

use Moo;

with 'Web::Dispatch::ToApp';

for (qw(match run)) {
  has "_${_}" => (is => 'ro', required => 1, init_arg => $_);
}

sub call {
  my ($self, $env) = @_;
  if (my ($env_delta, @match) = $self->_match->($env)) {
    ($env_delta, $self->_curry(@match));
  } else {
    ()
  }
}

sub _curry {
  my ($self, @args) = @_;
  my $run = $self->_run;
  sub { $run->(@args, $_[0]) };
}

1;