Hubot::Brain - Represents somewhat persistent storage for the robot.
version 0.2.8
$robot->brain->{data}{key} = ''; # scalar $robot->brain->{data}{key} = {}; # HashRef $robot->brain->{data}{key} = []; # ArrayRef
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.
subscribe brain's save
and close
event.
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; } );
Hyungsuk Hong <hshong@perl.kr>
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.