Take me over?
NAME
Verby::Step::Closure - Quick and dirty (in the fun sense, like playing with mud) step generator.
SYNOPSIS
use Verby::Step::Closure qw/step/;
my $s = step "Action::Class" => sub {
# called before action
}, sub {
# called after action
};
DESCRIPTION
This module eases the creation of step objects, by using closures and accessors. It's purpose is to be able to rapidly create simple steps based on an action class and some clalbacks.
Since Verby::Action and Verby::Step are separated, this may lead to unnecessary typing, class creation, or other silly crap. Verby::Step::Closure's purpose is to make this boundry unnoticable, so that when you don't need it it doesn't get in your way.
EXPORTED FUNCTIONS
- step $action_class ?$pre ?$post
-
This function (optionally exportable) is used as a quick and dirty constructor.
It will require $action_class with UNIVERSAL::require, and then create a new Verby::Step::Closure with the
action
field set to an instance.
METHODS
- new $action_class ?$pre ?$post
-
Creates a new anonymous step.
- depends *@steps
-
Just a plain old accessor.
- add_deps *@steps
-
Append more steps to the dep list.
- is_satisfied
-
Calls the pre hook,
verify
and then the post hook. - do
-
Calls the pre hook,
do
, and lastly the post hook. - stringify
-
Stringifies to the action's class.
- get
- set
-
Replacements for Class::Accessor's methods that convert between lists and array references.
- can $method
-
A special case of "can" in UNIVERSAL that will return false for methods the action can't fulfill.
EXAMPLE
The test files, as well as the demo scripts make extensive use of Verby::Step::Closure. Look at scripts/module_builder.pl for some documented usage.
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.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.