From: Marcus Ramberg Date: Thu, 26 Jun 2008 16:30:56 +0000 (+0000) Subject: Add stringify back for action, and test X-Git-Tag: 5.8000_03~86 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=2055d9ad6304f9db74cb05ec8ee0146ce319e8e4;hp=843c92335c9a365347740342df6f8d3506486432 Add stringify back for action, and test --- diff --git a/Changes b/Changes index ffb920e..95f397b 100644 --- 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 diff --git a/lib/Catalyst/Action.pm b/lib/Catalyst/Action.pm index 6758e86..1a23b16 100644 --- a/lib/Catalyst/Action.pm +++ b/lib/Catalyst/Action.pm @@ -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/); diff --git a/t/unit_core_action_for.t b/t/unit_core_action_for.t index 71772f8..fe47161 100644 --- a/t/unit_core_action_for.t +++ b/t/unit_core_action_for.t @@ -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');