Bot::BasicBot::Pluggable::Store(3) base class for the back-end pluggable store


version 0.98


my $store = Bot::BasicBot::Pluggable::Store->new( option => "value" );
my $namespace = "MyModule";
for ( $store->keys($namespace) ) {
my $value = $store->get($namespace, $_);
$store->set( $namespace, $_, "$value and your momma." );

Store classes should subclass this and provide some persistent way of storing things.


Standard "new" method, blesses a hash into the right class and puts any key/value pairs passed to it into the blessed hash. If called with an hash argument as its first argument, new_from_hashref will be run with the hash as its only argument. See ``new_from_hashref'' for the possible keys and values. You can also pass a string and it will try to call new_from_hashref with a hash reference { type => $string }. Calls "load()" to load any internal variables, then "init", which you can also override in your module.
new_from_hashref( $hashref )
Intended to be called as class method to dynamically create a store object. It expects a hash reference as its only argument. The only required hash element is a string specified by type. This should be either a fully qualified classname or a colonless string that is appended to Bot::BasicBot::Pluggable::Store. All other arguments are passed down to the real object constructor.
Called as part of new class construction, before "load()".
Called as part of new class construction, after "init()".
Subclass me. But, only if you want to. See as an example.
Returns a list of all store keys for the passed $namespace.

If you pass $regex then it will only pass the keys matching $regex

get($namespace, $variable)
Returns the stored value of the $variable from $namespace.
set($namespace, $variable, $value)
Sets stored value for $variable to $value in $namespace. Returns store object.
unset($namespace, $variable)
Removes the $variable from the store. Returns store object.
Returns a list of all namespaces in the store.
Dumps the complete store to a huge Storable scalar. This is mostly so you can convert from one store to another easily, i.e.:

  my $from = Bot::BasicBot::Pluggable::Store::Storable->new();
  my $to   = Bot::BasicBot::Pluggable::Store::DBI->new( ... );
  $to->restore( $from->dump );

"dump" is written generally so you don't have to re-implement it in subclasses.

Restores the store from a dump().


Mario Domgoergen <[email protected]>

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