-
-
28 Aug 2009 15:03:01 UTC
- Distribution: Class-Workflow
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Issues (0)
- Testers (642 / 14 / 1)
- Kwalitee
Bus factor: 3- % Coverage
- License: unknown
- Activity
24 month- Tools
- Download (31.08KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- Data::Compare
- Moose
- MooseX::Clone
- Set::Object
- Test::More
- Test::use::ok
- YAML::Syck
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
Class::Workflow::Transition::Simple - A useful class (or base class) for writing transitions.
SYNOPSIS
use Class::Workflow::Transition::Simple; my $t = Class::Workflow::Transition::Simple->new( name => "feed", to_state => $not_hungry, # Class::Workflow::Transition::State body_sets_fields => 1, body => sub { my ( $self, $instance, @args ) = @_; my $remain = $global_food_warehouse->reduce_quantity; return ( remaining_food => $remain, ); }, );
DESCRIPTION
FIELDS
- name
-
This is just a string. It can be used to identify the transition in a parent object like
Class::Workflow
if any. - to_state
-
This is the state the transition will transfer to. This comes from
Class::Workflow::Transition::Deterministic
. - body
-
This is an optional sub (it defaults to
<sub { }
>) which will be called during apply, after all validation has passed.The body is invoked as a method on the transition.
See
body_sets_fields
for the semantics of the return value. - body_sets_fields
-
When true, then the body is expected to return a hash of fields to override in the instance. See Class::Workflow::Transition::Deterministic for details.
This field is present to avoid writing code like this:
return ( {}, @return_values );
When you don't want to set fields in the instance.
Defaults to false (just write return @return_value, set to true to set fields).
See also
set_fields
. - set_fields
-
This field is a hash ref that will be used as the list of fields to set on the instance when
body_sets_fields
is false.If your transition does not need to dynamically set fields you should probably use this.
Defaults to
{}
. - validate
- validators
- clear_validators
- add_validators
-
These methods come from Class::Workflow::Transition::Validate::Simple.
ROLES
This class consumes the following roles:
Module Install Instructions
To install Class::Workflow, copy and paste the appropriate command in to your terminal.
cpanm Class::Workflow
perl -MCPAN -e shell install Class::Workflow
For more information on module installation, please visit the detailed CPAN module installation guide.