[0.009] ...
+ - action classes are now moosified after loading, this means that
+ RenderView should now work with isa. (thanks to all reporters!)
+ - documented 'isa' action class option (experimental!)
[0.008] Tue Aug 18 19:59:57 CEST 2009
- default_inner now ignores arguments
use MooseX::Declare;
use Class::MOP;
+use Moose::Meta::Class;
role CatalystX::Declare::Controller::DetermineActionClass
with CatalystX::Declare::Controller::QualifyClassNames {
my $fq_class = $self->_qualify_class_name('Action', $action_class);
Class::MOP::load_class($fq_class);
+ Moose::Meta::Class->initialize($fq_class);
$args{attributes}{ActionClass} ||= [$fq_class];
}
}
+=head2 Action Classes
+
+B<This option is even more experimental>
+
+You might want to create an action with a different class than the usual
+L<Catalyst::Action>. A usual suspect here is L<Catalyst::Action::RenderView>.
+You can use the C<isa> option (did I mention it's experimental?) to specify
+what class to use:
+
+ controller MyApp::Web::Controller::Root {
+
+ $CLASS->config(namespace => '');
+
+ action end isa RenderView;
+ }
+
+The loaded class will be L<Moose>ified, so we are able to apply essential
+roles.
+
=head1 ROLES
=over
--- /dev/null
+#!/usr/bin/env perl
+use strict;
+use warnings;
+
+use FindBin;
+use lib "$FindBin::Bin/lib";
+
+use Test::More;
+
+eval { require Catalyst::Action::RenderView };
+plan skip_all => 'Catalyst::Action::RenderView required'
+ if $@;
+
+use Catalyst::Test 'RenderViewTestApp';
+
+is get('/foo'), 'RenderViewTestApp::View::Test', 'view was reached via RenderView';
+
+done_testing;
--- /dev/null
+use CatalystX::Declare;
+
+application RenderViewTestApp with CatalystX::Declare::TestPlugin {
+
+ $CLASS->config(name => 'RenderView TestApp');
+}
+
+
--- /dev/null
+use CatalystX::Declare;
+
+controller RenderViewTestApp::Controller::Root {
+
+ $CLASS->config(namespace => '');
+
+
+ action base as '' under '/';
+
+ final action foo under base {
+ $ctx->stash(current_view => 'Test');
+ }
+
+ action end isa RenderView;
+}
--- /dev/null
+use CatalystX::Declare;
+
+view RenderViewTestApp::View::Test {
+
+ method process (Catalyst $ctx) {
+ $ctx->response->body( $CLASS );
+ }
+}