[Catalyst-commits] r11977 - Catalyst-Runtime/5.80/branches/basic-app-ctx-separation-cleaned/t/lib/TestAppPluginWithConstructor

zby at dev.catalyst.perl.org zby at dev.catalyst.perl.org
Mon Nov 23 20:08:42 GMT 2009


Author: zby
Date: 2009-11-23 20:08:41 +0000 (Mon, 23 Nov 2009)
New Revision: 11977

Added:
   Catalyst-Runtime/5.80/branches/basic-app-ctx-separation-cleaned/t/lib/TestAppPluginWithConstructor/Context.pm
Log:
Context for TestAppPluginWithConstructor

Added: Catalyst-Runtime/5.80/branches/basic-app-ctx-separation-cleaned/t/lib/TestAppPluginWithConstructor/Context.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/basic-app-ctx-separation-cleaned/t/lib/TestAppPluginWithConstructor/Context.pm	                        (rev 0)
+++ Catalyst-Runtime/5.80/branches/basic-app-ctx-separation-cleaned/t/lib/TestAppPluginWithConstructor/Context.pm	2009-11-23 20:08:41 UTC (rev 11977)
@@ -0,0 +1,55 @@
+package TestAppPluginWithConstructor::Context;
+use Moose;
+extends 'Catalyst::Context'; 
+
+if (eval { Class::MOP::load_class('CatalystX::LeakChecker'); 1 }) {
+    with 'CatalystX::LeakChecker';
+
+    has leaks => (
+        is      => 'ro',
+        default => sub { [] },
+    );
+}
+
+sub found_leaks {
+    my ($ctx, @leaks) = @_;
+    push @{ $ctx->leaks }, @leaks;
+}
+
+sub count_leaks {
+    my ($ctx) = @_;
+    return scalar @{ $ctx->leaks };
+}
+
+sub execute {
+    my $c      = shift;
+    my $class  = ref( $c->component( $_[0] ) ) || $_[0];
+    my $action = $_[1]->reverse;
+
+    my $method;
+
+    if ( $action =~ /->(\w+)$/ ) {
+        $method = $1;
+    }
+    elsif ( $action =~ /\/(\w+)$/ ) {
+        $method = $1;
+    }
+    elsif ( $action =~ /^(\w+)$/ ) {
+        $method = $action;
+    }
+
+    if ( $class && $method && $method !~ /^_/ ) {
+        my $executed = sprintf( "%s->%s", $class, $method );
+        my @executed = $c->response->headers->header('X-Catalyst-Executed');
+        push @executed, $executed;
+        $c->response->headers->header(
+            'X-Catalyst-Executed' => join ', ',
+            @executed
+        );
+    }
+    no warnings 'recursion';
+    return $c->SUPER::execute(@_);
+}
+
+1;
+




More information about the Catalyst-commits mailing list