The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Mojo::Stateful - Stateful Base Class

SYNOPSIS

    use base 'Mojo::Stateful';

DESCRIPTION

Mojo::Stateful is a base class for state keeping instances.

ATTRIBUTES

Mojo::Stateful implements the following attributes.

state_cb

   my $cb    = $stateful->state_cb;
   $stateful = $stateful->state_cb(sub {...});

METHODS

Mojo::Stateful inherits all methods from Mojo::Base and implements the following new ones.

done

    $stateful = $stateful->done;

error

    my $error = $stateful->error;
    $stateful = $stateful->error('Parser error: test 123');

has_error

    my $has_error = $stateful->has_error;

is_done

    my $done = $stateful->is_done;

is_finished

    my $finished = $stateful->is_finished;

is_state

    my $is_state = $stateful->is_state('writing');
    my $is_state = $stateful->is_state(qw/error reading writing/);

state

    my $state = $stateful->state;
    $stateful = $stateful->state('writing');