++ed by:
KEEDI

1 PAUSE user
4 non-PAUSE users.

Hyungsuk Hong

NAME

Hubot::Brain - Represents somewhat persistent storage for the robot.

VERSION

version 0.2.8

SYNOPSIS

    $robot->brain->{data}{key} = ''; # scalar
    $robot->brain->{data}{key} = {}; # HashRef
    $robot->brain->{data}{key} = []; # ArrayRef

DESCRIPTION

Brain with external storage like a Hubot::Scrips::redisBrain, value must be a Scalar or HashRef or ArrayRef.

$robot->brain->data will convert to json string and stored to external storage. so, if you trying to store perl object, it will fail.

without external storage, everything is fine to store to memory.

USE EXTERNAL STORAGE

step 1

subscribe brain's save and close event.

step 2

robot boots time, save will emitted. robot shutdown time, close will emitted.

    my $externalStorage = Great::Big::White::World->new;
    $robot->brain->on(
        'save',
        sub {
            my ($e, $data) = @_;
            $externalStorage->save($data);
        }
    );

    $robot->brain->on(
        'close',
        sub {
            $externalStorage->quit;
        }
    );

SEE ALSO

Hubot::Scripts::redisBrain

AUTHOR

Hyungsuk Hong <hshong@perl.kr>

COPYRIGHT AND LICENSE

This software is copyright (c) 2012 by Hyungsuk Hong.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.