Scroll to navigation

Bot::BasicBot::Pluggable::Store(3pm) User Contributed Perl Documentation Bot::BasicBot::Pluggable::Store(3pm)

NAME

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

VERSION

version 1.30

SYNOPSIS

  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.

METHODS

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.
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 ...Store::Storable.pm 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

Returns the stored value of the $variable from $namespace.
Sets stored value for $variable to $value in $namespace. Returns store object.
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().

AUTHOR

Mario Domgoergen <mdom@cpan.org>

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

SEE ALSO

Bot::BasicBot::Pluggable

Bot::BasicBot::Pluggable::Module

2024-08-24 perl v5.38.2