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

SEE ALSO

104       See Class::MakeMethods for general information about this distribution.
105
106       See Class::MakeMethods::Template for information about this family of
107       subclasses.
108
109
110
111perl v5.8.8                       2004-09-06MakeMethods::Template::ClassName(3)
Impressum