1MakeMethods::Template::UCslearssCNoanmter(i3b)uted PerlMDaokceuMmeetnhtoadtsi:o:nTemplate::ClassName(3)
2
3
4

NAME

6       Class::MakeMethods::Template::ClassName - Access object's class
7

SYNOPSIS

9         package MyObject;
10         use Class::MakeMethods::Template::ClassName (
11           subclass_name => [ 'type' ]
12         );
13         ...
14         package main;
15         my $object = MyObject->new;
16
17         $object->type('Foo')
18         # reblesses object to MyObject::Foo subclass
19
20         print $object->type();
21         # prints "Foo".
22

DESCRIPTION

24       These method types access or change information about the class an
25       object is associated with.
26
27   class_name
28       Called without arguments, returns the class name.
29
30       If called with an argument, reblesses object into that class.  If the
31       class doesn't already exist, it will be created.
32
33   subclass_name
34       Called without arguments, returns the subclass name.
35
36       If called with an argument, reblesses object into that subclass.  If
37       the subclass doesn't already exist, it will be created.
38
39       The subclass name is written as follows:
40
41       ·   if it's the original, defining class: empty
42
43       ·   if its a a package within the namespace of the original: the
44           distingushing name within that namespace, without leading "::"
45
46       ·   if it's a package elsewhere: the full name with leading "::"
47
48   static_hash_classname
49       Provides a shared hash mapping keys to class names.
50
51         class_registry => [ qw/ foo / ]
52
53       Takes a single string or a reference to an array of strings as its
54       argument.  For each string, creates a new anonymous hash and associated
55       accessor methods that will map scalar values to classes in the calling
56       package's subclass hiearchy.
57
58       The accessor methods provide an interface to the hash as illustrated
59       below.  Note that several of these functions operate quite differently
60       depending on the number of arguments passed, or the context in which
61       they are called.
62
63       @indexes = $class_or_ref->x;
64           Returns the scalar values that are indexes associated with this
65           class, or the class of this object.
66
67       $class = $class_or_ref->x( $index );
68           Returns the class name associated with the provided index value.
69
70       @classes = $class_or_ref->x( @indexes );
71           Returns the associated classes for each index in order.
72
73       @all_indexes = $class_or_ref->x_keys;
74           Returns a list of the indexes defined for this registry.
75
76       @all_classes = $class_or_ref->x_values;
77           Returns a list of the classes associated with this registry.
78
79       @all_classes = $class_or_ref->unique_x_values;
80           Returns a list of the classes associated with this registry, with
81           no more than one occurance of any value.
82
83       %mapping = $class_or_ref->x_hash;
84           Return the key-value pairs used to store this attribute
85
86       $mapping_ref = $class_or_ref->x_hash;
87           Returns a reference to the hash used for the mapping.
88
89       $class_or_ref->add_x( @indexes );
90           Adds an entry in the hash for each of the provided indexes, mapping
91           it to this class, or the class of this object.
92
93       $class_or_ref->clear_x;
94           Removes those entries from the hash whose values are this class, or
95           the class of this object.
96
97       $class_or_ref->clear_xs( @indexes );
98           Remove all entries from the hash.
99

SEE ALSO

101       See Class::MakeMethods for general information about this distribution.
102
103       See Class::MakeMethods::Template for information about this family of
104       subclasses.
105
106
107
108perl v5.32.0                      2020-07-28MakeMethods::Template::ClassName(3)
Impressum