RapidApp::Role::Controller - Role for RapidApp Controller Modules
package MyApp::Module::MyModule; use Moose; with 'RapidApp::Role::Controller';
This is the main role for RapidApp Modules which implement a Controller interface. Documentation still TDB...
See: RapidApp::Manual::Modules
This method handles a request.
controller_dispatch performs the standard RapidApp dispatch processing for a Module.
If the first argument names an action, the action is executed.
If the first argument names a sub-module, the processing is passed to the sub-module.
If the first argument does not match anything, then the default action is called, if specified, otherwise a 404 is returned to the user.
If there are no arguments, and the client was not requesting JSON, the viewport is executed.
Else, content is called, and its return value is passed to render_data.
This routine handles the execution of a selected action. The action must exist. For actions that map to coderefs, the coderef is executed. For actions that map to strings, a method of that name is called on $self.
This is a very DWIM sort of routine that takes its parameter (likely the return value of content or an action) and picks an appropriate view for it, possibly ignoring it altogether.
If the action generated a body, no view is needed, and the parameter is ignored.
If the action chose its own view, no further processing is done, and the parameter is returned.
If the controller is configured to render json (the default) and the parameter isn't blacklisted in no_json_ref_types, and the parameter isn't a plain string, the RapidApp::JSON view is chosen. The parameter is returned (as-is) to get passed back to TopController who passes it to the view.
Else, the data is treated as an explicit string for the body. The body is assigned, and returned.
examples
$self->set_response_callback( 'Ext.ux.MyFunc' ); $self->set_response_callback( alert => 'foo!' ); $self->set_response_callback( 'Ext.Msg.alert' => ( 'A message!!', 'this is awesome!!' ) ); my $func = RapidApp::JSONFunc->new( raw => 1, func => 'function(){ console.log("anon!!"); console.dir(this.response); }' ); $self->response_callback_scoped(1); $self->set_response_callback( $func => ( "arg1",{ key_in_arg2 => 'blah!!!' },'arg3',\1 ) );
RapidApp::Manual::Modules
Henry Van Styn <vanstyn@cpan.org>
This software is copyright (c) 2009 by IntelliTree Solutions llc.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install RapidApp, copy and paste the appropriate command in to your terminal.
cpanm
cpanm RapidApp
CPAN shell
perl -MCPAN -e shell install RapidApp
For more information on module installation, please visit the detailed CPAN module installation guide.