Class::Workflow::Instance - An instance in a workflow, with state and history. |
Class::Workflow::Instance - An instance in a workflow, with state and history.
package MyInstance; use Moose;
with qw(Class::Workflow::Instance);
my $instance = MyInstance->new( state => $initial_state );
my $new_instance = $transition->apply( $instance, @args );
# $instance is in $initial state, no transitions applied # $new_instance may be in another state, $transition has been applied # $new_instance->prev == $instance
A workflow instance encapsulates the current state and workflow history on behalf of some parent object that needs state management.
In the Class::Workflow manpage these instances are functionally pure, that is they don't change but instead derive their parent copies, and the reference from a given item is to the most recently derived copy.
This eases auditing, reverting, and the writing of transitions.
prev
.
prev
to the current object, and shadowing the
fields with new values from the key value pair list in the arguments.
As a special case values of undef
in %fields will cause the clearer to be
called, not the setter.
Class::Workflow::Instance - An instance in a workflow, with state and history. |