Take me over?
NAME
Verby::Step - A base class representing a single thing to be executed by Verby::Dispatcher.
SYNOPSIS
use base qw/Verby::Step/;
Or perhaps more appropriate
use Verby::Step::Closure qw/step/;
my $step = step "Some::Action",
sub { warn "before" },
sub { warn "after" };
DESCRIPTION
A step in the Verby system is like an instance of an action.
A step is much like a makefile target. It can depend on other steps, and when appropriate will be told to be executed.
The difference between a Verby::Step and a Verby::Action is that an action is usually just reusable code to implement the verification and execution
A step manages the invocation of an action, typically by massaging the context before delegating, and re-exporting meaningful data to the parent context when finished. It also tells the system when to execute, by specifying dependencies.
The distinction is that an action is something you do, and a step is something you do before and after others.
METHODS
All methods should be subclassed except for provides_cxt
. This class is nearly completely virtual.
- depends
-
Subclass this to return a list of other steps to depend on.
- is_satisfied
-
This method should return a true value if the step does not need to be executed.
Typically a delegation to "verify" in Verby::Action. They are named differently, because
is_satisfied
implies state. The Verby::Dispatcher will sometimes make assumptions, without asking the step to check that it is satisfied. - provides_cxt
- do
- start
- finish
- pump
-
These are basically delegations to the corresponding Verby::Action methods.
The only interesting thing to do here is to fudge the context up a bit. For example, if your action assumes the
path
key to be in the context, but you chosethe_path_to_the_thing
to be in your config, this is the place to do:sub do { my ($self, $c) = @_; # prepare for the action $c->path($c->the_path_to_the_thing); $self->action->do($c); # pass data from the action to the next steps $c->export("some_key_the_action_set"); }
Verby::Step::Closure provides a convenient way to get this behavior for free.
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 by Infinity Interactive, Inc.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.