NAME

Workflow::Lite::Role::Workflow - A role comprising the main functionality for workflows

SYNOPSIS

package MyWorkflow;

use namespace::autoclean;
use Moose;

with qw( Workflow::Lite::Role::Workflow );

__PACKAGE__->_steps->{START} = sub {
  my ( $self, $text ) = @_;

  print 'This is the START step: ', $text, "\n";
  $self->flow( 'foo' );

  reverse $text
};

__PACKAGE__->_steps->{foo} = sub {
  my ( $self, $text ) = @_;

  print 'This is the foo step: ', $text, "\n";
  $self->flow( 'bar' );

  reverse $text
};

__PACKAGE__->_steps->{bar} = sub {
  my ( $self, $text ) = @_;

  print 'This is the bar step: ', $text, "\n";
  $self->end;

  reverse $text
};

1

...

my $wf = MyWorkflow->new;

my @words = qw( Bar Foo Start );

while( $wf->is_flowing ) {
  my $rv = $wf->work( pop @words );
  print '  -> ', $rv, "\n";
}

DESCRIPTION

Workflow::Lite::Role::Workflow is a role that implements the functionality necessary for handling workflows. This role is applied automatically when useing Workflow::Lite.

CLASS ATTRIBUTES

_steps

A HashRef that contains the defined steps for the class. Steps are simply CodeRefs that get called when the named step is executed in a call to work().

OBJECT ATTRIBUTES

_step

Contains the name of the step to be executed upon the next call to work(). This defaults to 'START', but can be overridden if necessary.

_flowing

A boolean value that provides the flowing status of the workflow.

OBJECT METHODS

work( [@args] )

Runs the handler for the current step. Any arguments provided in @args are passed to the handler. Handlers are run as object methods so $self is passed as well. The return from the handler is passed as-is back from work(). If the workflow is not currently flowing or the current step does not have a handler, an exception is thrown.

flow( $step )

Flows to the step named by $step. If $step has not been previously defined, an exception is thrown.

end()

Halts the workflow. Further calls to work() will result in an exception being thrown.

is_flowing()

Returns true if the workflow is still flowing, false otherwise.

BUGS

None are known at this time, but if you find one, please feel free to submit a report to the author.

AUTHOR

jason hord <pravus@cpan.org>

SEE ALSO

Workflow::Lite

COPYRIGHT

Copyright (c) 2011, jason hord

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 135:

'=item' outside of any '=over'