Bot::B...::Store(3pm)

πŸ“¦
version 1.30 Β· 5 versions
, in ubuntu resolute, ubuntu stonking

πŸ’– Bot::B...::Store β€” bestie edition πŸ’–

okay so this is the manpage for Bot::BasicBot::Pluggable::Store, from the User Contributed Perl Documentation section (3pm). it's the base class for the back-end pluggable store, and honestly? it's giving foundation of everything. it's the blueprint other store classes inherit from. no cap.


✨ VERSION ✨

version 1.30 β€” that's the one, bestie πŸ’…


🌸 SYNOPSIS 🌸

here's the vibe, copy-paste ready:

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." );
}

and the whole point of this class, the mission statement: Store classes should subclass this and provide some persistent way of storing things. that's it. that's the assignment. if you want your stuff to actually stick around, you subclass this. periodt. 🫢


πŸŽ€ METHODS πŸŽ€

πŸ’« new()

the standard new method, iconic behaviour only: it blesses a hash into the right class and drops any key/value pairs you passed into the blessed hash.

  • if you call it with a hash argument as its first argument, new_from_hashref gets run with that hash as its only argument. the possible keys and values live in "new_from_hashref" (scroll down, bestie).
  • you can also pass a string and it will try to call new_from_hashref with a hash reference { type => $string }. cute, right?
  • then it calls load() to load any internal variables, then "init" β€” which, yes, you can override in your own module. main character energy, go off. πŸ‘‘

πŸ’« new_from_hashref( $hashref )

this one is intended to be called as a class method, so you can 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.
  • that type should be either a fully qualified classname, or a colonless string that gets appended to Bot::BasicBot::Pluggable::Store.
  • every other argument gets passed down to the real object constructor. πŸ¦‹

πŸ’« init()

called as part of new class construction, before load(). 🌱

πŸ’« load()

called as part of new class construction, after init(). 🌿

πŸ’« save()

subclass me. but, only if you want to. πŸ™ˆ

see ...Store::Storable.pm as an example. that's the inspo, bestie.

πŸ’« keys($namespace,[$regex])

returns a list of all store keys for the passed $namespace.

if you pass $regex then it will only pass the keys matching $regex. filtering queen behaviour πŸ’…

πŸ’« get($namespace, $variable)

returns the stored value of the $variable from $namespace. that's it, that's the whole thing.

πŸ’« 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. bye bestie πŸ‘‹

πŸ’« namespaces()

returns a list of all namespaces in the store. all of them. every single one. 🌈

πŸ’« dump()

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 );

and here's the slay part: "dump" is written generally, so you don't have to re-implement it in subclasses. we love a reusable method. ✨

πŸ’« restore($data)

restores the store from a dump(). the glow-up reversal arc πŸ’œ


πŸ‘‘ 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. (yes bestie, same terms as Perl itself, we love a permissive license 🫢)


πŸ”— SEE ALSO πŸ”—

  • Bot::BasicBot::Pluggable
  • Bot::BasicBot::Pluggable::Module

and that's the whole page, fr fr πŸ’– this was Bot::B...::Store(3pm) from perl v5.40.0, dated 2024-08-24. go forth and subclass, bestie β€” you're gonna eat. πŸ’…πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from