MakeMe...ritable(3pm)
π NAME π
okay so this is the MakeMe...ritable(3pm) page from User Contributed Perl Documentation, and the main character is Class::MakeMethods::Utility::Inheritable β literally "Inheritable" data. π
β¨
β¨ SYNOPSIS β¨
bestie, here's the whole vibe in code, copy-paste exact:
package MyClass;
sub new { ... }
package MySubclass;
@ISA = 'MyClass';
...
my $obj = MyClass->new(...);
my $subobj = MySubclass->new(...);
use Class::MakeMethods::Utility::Inheritable qw(get_vvalue set_vvalue );
my $dataset = {};
set_vvalue($dataset, 'MyClass', 'Foobar'); # Set value for class
get_vvalue($dataset, 'MyClass'); # Gets value "Foobar"
get_vvalue($dataset, $obj); # Objects "inherit"
set_vvalue($dataset, $obj, 'Foible'); # Until you override
get_vvalue($dataset, $obj); # Now finds "Foible"
get_vvalue($dataset, 'MySubclass'); # Subclass "inherits"
get_vvalue($dataset, $subobj); # As do its objects
set_vvalue($dataset, 'MySubclass', 'Foozle'); # Until we override it
get_vvalue($dataset, 'MySubclass'); # Now finds "Foozle"
get_vvalue($dataset, $subobj); # Change cascades down
set_vvalue($dataset, $subobj, 'Foolish'); # Until we override again
get_vvalue($dataset, 'MyClass'); # Superclass is unchanged
π DESCRIPTION π
So here's the tea: this module hands you several functions that let you store values in a hash corresponding to both objects and classes, and then retrieve those values by searching an object's inheritance tree until it finds a matching entry. π¦
This functionality is used by Class::MakeMethods::Standard::Inheritable and Class::MakeMethods::Composite::Inheritable to construct methods that can both store class data and be overridden on a per-object level. periodt. π
π₯ REFERENCE π₯
three functions, three little moments β let's go:
π¦ find_vself π¦
$vself = find_vself( $dataset, $instance );
Searches $instance's inheritance tree until it finds a matching entry in the dataset, and returns either the instance, the class that matched, or undef. that's the whole function, no cap. π
π get_vvalue π
$value = get_vvalue( $dataset, $instance );
Searches $instance's inheritance tree until it finds a matching entry in the dataset, and returns that value. slay. π
π set_vvalue π
$value = set_vvalue( $dataset, $instance, $value );
Searches $instance's inheritance tree until it finds a matching entry in the dataset, and returns that value.
bestie, yes, the original description for set_vvalue also says "returns that value" β I'm not changing a single word of the lore. π
okay that's the whole page bestie π this was MakeMe...ritable(3pm) from User Contributed Perl Documentation, built for perl v5.36.0, dated 2022-10-13 β mwah π«Άβ¨
π¦ where this page comes from
- ubuntu noble: libclass-makemethods-perl 1.01-7 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libclass-makemethods-perl 1.01-7 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libclass-makemethods-perl 1.01-7 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms