NAME
Mojo::Stateful - Stateful Base Class
SYNOPSIS
use base 'Mojo::Stateful';
DESCRIPTION
Mojo::Stateful is an abstract base class for state keeping objects.
ATTRIBUTES
Mojo::Stateful implements the following attributes.
"state_cb"
my $cb = $stateful->state_cb;$stateful = $stateful->state_cb(sub {...});
Callback that will be invoked whenever the state of this object changes.
METHODS
Mojo::Stateful inherits all methods from Mojo::Base and implements the following new ones.
"done"
$stateful = $stateful->done;
Shortcut for setting the current state to "done".
"error"
my $message = $stateful->error;my ($message, $code) = $stateful->error;$stateful = $stateful->error('Parser error.');$stateful = $stateful->error('Parser error.', 500);
Shortcut for setting the current state to "error" with "code" and "message".
"has_error"
my $has_error = $stateful->has_error;
Check if an error occured.
"is_done"
my $done = $stateful->is_done;
Check if the state machine is "done".
"is_finished"
my $finished = $stateful->is_finished;
Check if the state machine is finished, this includes the states "done", "done_with_leftovers" and "error".
"is_state"
my $is_state = $stateful->is_state('writing');my $is_state = $stateful->is_state(qw/error reading writing/);
Check if the state machine is currently in a specific state.
"state"
my $state = $stateful->state;$stateful = $stateful->state('writing');
The current state.
SEE ALSO
Mojolicious, Mojolicious::Guides, <http://mojolicious.org>.