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
saveandcloseevent. - step 2
-
robot boots time,
savewill emitted. robot shutdown time,closewill 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
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.