NAME

Verby::Action - The base role for an action in Verby.

SYNOPSIS

package MyAction;
use Moose;

with qw/Verby::Action/;

sub do { ... }

sub verify { ... }

DESCRIPTION

A Verby::Action is an object encapsulating reusable code. Steps usually delegate to actions, for the actual grunt work.

METHODS

new

Instantiate an action. Actions should be able to live indefinitely, and should not carry internal state with them. All the parameters for do or verify are provided within the context.

The action instance data should only be used to configure action "flavours", controlling behavior that should not be parameter sensitive (configuration data).

do $cxt

The thing that the action really does. For example

package Verby::Action::Download;

sub do {
	my ($self, $c) = @_;
	system("wget", "-O", $c->file, $c->url);
}

Will use wget to download $c->url to $c->file.

This is a bad example though, you ought to subclass Verby::Action::Run if you want to run a command.

verify $cxt

Perform a boolean check - whether or not the action is completed, for a given set of arguments.

For example, if do downloads $c->file from $c->url, then the verify method would look like:

sub verify {
	my ($self, $c) = @_;
	-f $c->file;
}

or it could even make a HEAD request and make sure that $c->file is up to date.

confirm $cxt

Typically called at the end of an action's do:

sub do {
	my ($self, $c) = @_;
	...
	$self->confirm($c);
}

It will call $c->logger->log_and_die unless verify returns a true value.

If $c->error contains a string then it'll be printed as well.

ASYNCHRONOUS ACTIONS

Since Verby is an abstraction layer over POE and every step get's it's own POE::Session, an actions do method can create child sessions, and the parent session will wait till they are completed, as per default POE behavior.

Note that this documentation assumes delegation of step methods to action methods.

Verby::Dispatcher actually has nothing to do with Verby::Action, it's just that typically a Verby::Step is just a thin wrapper for Verby::Action, so the methods roughly correspond.

See Verby::Step::Closure for a trivial way to generate steps given a Verby::Action subclass.

BUGS

None that we are aware of. Of course, if you find a bug, let us know, and we will be sure to fix it.

CODE COVERAGE

We use Devel::Cover to test the code coverage of the tests, please refer to COVERAGE section of the Verby module for more information.

SEE ALSO

AUTHOR

Yuval Kogman, <nothingmuch@woobling.org>

COPYRIGHT AND LICENSE

Copyright 2005-2008 by Infinity Interactive, Inc.

http://www.iinteractive.com

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

1 POD Error

The following errors were encountered while parsing the POD:

Around line 117:

=back without =over