Mojo::Stateful(3pm)

Mojo::Stateful3pm

Stateful base class

Usage

    use base 'Mojo::Stateful';

Overview

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.

From libmojolicious-perl 0.999926-1+squeeze2 in Debian 6.0 (Squeeze). Parsed by carta from the page's man source.