The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Action::Generic::Plugin::Custom - Run a custom bit of code

SYNOPSIS

Create an action:

 my $action = $controller->action( 
  type => 'Custom',
  name => 'A Custom Action',
  code => sub { print "Hello world!\n" }
 );

.. add it to the controller ..

 $controller->add_actions( $action );

And later, it gets run..

 $controller->run();  # "Hello, world!\n" 

DESCRIPTION

The Custom action allows for running of arbitrary code. When creating the action, a code attribute must be supplied, and must be a CodeRef (in Moose terms).

Should you wish to pass arguments to the CODEREF, you should probably do it when creating the object. Perhaps something like:

 my $foo = 'ba-nay-nay';

 my $action = $controller->action(
        name => 'An action, with parameters',
        type => 'Custom',
        code => sub { 
     print $foo, "\n";          
   }
 );

It's like scoping works, or something!

Attributes

code

A CODEREF containing the code to run. In the results hashref, for this action, the return value of the coderef is captured and saved.

It is possible that the code executed could do something like die or something equally odd. I'd not suggest it.

LICENSE AND COPYING

This library is free software; you may redistribute and/or modify it under the same terms as Perl itself.

BUGS

Probably. Patches welcome!

AUTHOR

Dave Houston <dhouston@cpan.org>, 2010