factor dispatcher out into Web::Dispatch
[catagits/Web-Simple.git] / lib / Web / Simple / DispatchNode.pm
diff --git a/lib/Web/Simple/DispatchNode.pm b/lib/Web/Simple/DispatchNode.pm
new file mode 100644 (file)
index 0000000..e00da02
--- /dev/null
@@ -0,0 +1,21 @@
+package Web::Simple::DispatchNode;
+
+use Moo;
+
+extends 'Web::Dispatch::Node';
+
+has _app_object => (is => 'ro', init_arg => 'app_object', required => 1);
+
+around _curry => sub {
+  my ($orig, $self) = (shift, shift);
+  my $app = $self->_app_object;
+  my $class = ref($app);
+  my $inner = $self->$orig($app, @_);
+  sub {
+    no strict 'refs';
+    local *{"${class}::self"} = \$app;
+    $inner->(@_);
+  }
+};
+
+1;