1MakeMethods::Utility::IUnsheerriCtoanbtlrei(b3u)ted PerlMaDkoecMuemtehnotdast:i:oUntility::Inheritable(3)
2
3
4

NAME

6       Class::MakeMethods::Utility::Inheritable - "Inheritable" data
7

SYNOPSIS

9         package MyClass;
10         sub new { ... }
11
12         package MySubclass;
13         @ISA = 'MyClass';
14         ...
15         my $obj = MyClass->new(...);
16         my $subobj = MySubclass->new(...);
17
18         use Class::MakeMethods::Utility::Inheritable qw(get_vvalue set_vvalue );
19
20         my $dataset = {};
21         set_vvalue($dataset, 'MyClass', 'Foobar');    # Set value for class
22         get_vvalue($dataset, 'MyClass');              # Gets value "Foobar"
23
24         get_vvalue($dataset, $obj);                   # Objects "inherit"
25         set_vvalue($dataset, $obj, 'Foible');         # Until you override
26         get_vvalue($dataset, $obj);                   # Now finds "Foible"
27
28         get_vvalue($dataset, 'MySubclass');           # Subclass "inherits"
29         get_vvalue($dataset, $subobj);                # As do its objects
30         set_vvalue($dataset, 'MySubclass', 'Foozle'); # Until we override it
31         get_vvalue($dataset, 'MySubclass');           # Now finds "Foozle"
32
33         get_vvalue($dataset, $subobj);                # Change cascades down
34         set_vvalue($dataset, $subobj, 'Foolish');     # Until we override again
35
36         get_vvalue($dataset, 'MyClass');              # Superclass is unchanged
37

DESCRIPTION

39       This module provides several functions which allow you to store values
40       in a hash corresponding to both objects and classes, and to retrieve
41       those values by searching a object's inheritance tree until it finds a
42       matching entry.
43
44       This functionality is used by Class::MakeMethods::Standard::Inheritable
45       and Class::MakeMethods::Composite::Inheritable to construct methods
46       that can both store class data and be overriden on a per-object level.
47

REFERENCE

49   find_vself
50         $vself = find_vself( $dataset, $instance );
51
52       Searches $instance's inheritance tree until it finds a matching entry
53       in the dataset, and returns either the instance, the class that
54       matched, or undef.
55
56   get_vvalue
57         $value = get_vvalue( $dataset, $instance );
58
59       Searches $instance's inheritance tree until it finds a matching entry
60       in the dataset, and returns that value
61
62   set_vvalue
63         $value = set_vvalue( $dataset, $instance, $value );
64
65       Searches $instance's inheritance tree until it finds a matching entry
66       in the dataset, and returns that value
67
68
69
70perl v5.32.0                      2020-07-2M8akeMethods::Utility::Inheritable(3)
Impressum