Add stringify back for action, and test
Marcus Ramberg [Thu, 26 Jun 2008 16:30:56 +0000 (16:30 +0000)]
Changes
lib/Catalyst/Action.pm
t/unit_core_action_for.t

diff --git a/Changes b/Changes
index ffb920e..95f397b 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,9 @@
 # This file documents the revision history for Perl extension Catalyst.
 
+5.8000
+        - Port to Moose
+        - Added test for action stringify
+
 5.7013
         - Fix subdirs for scripts that run in subdirs more than one level deep.
         - Added test and updated docs for handling the Authorization header
index 6758e86..1a23b16 100644 (file)
@@ -28,6 +28,21 @@ has code => (is => 'rw');
 
 no Moose;
 
+use overload (
+
+    # Stringify to reverse for debug output etc.
+    q{""} => sub { shift->{reverse} },
+
+    # Codulate to execute to invoke the encapsulated action coderef
+    '&{}' => sub { my $self = shift; sub { $self->execute(@_); }; },
+
+    # Make general $stuff still work
+    fallback => 1,
+
+);
+
+
+
 no warnings 'recursion';
 
 #__PACKAGE__->mk_accessors(qw/class namespace reverse attributes name code/);
index 71772f8..fe47161 100644 (file)
@@ -8,7 +8,7 @@ use lib "$FindBin::Bin/lib";
 
 use Test::More;
 
-plan tests => 3;
+plan tests => 4;
 
 use_ok('TestApp');
 
@@ -18,3 +18,6 @@ is(TestApp->action_for('global_action')->code, TestApp->can('global_action'),
 is(TestApp->controller('Args')->action_for('args')->code,
    TestApp::Controller::Args->can('args'),
    'action_for on controller ok');
+   is(TestApp->controller('Args')->action_for('args').'',
+      'args/args',
+      'action stringifies');