Debian Codegraph @

README

raw
1 NAME
2 Class::Handle - Create objects that are handles to Classes
3
4 SYNOPSIS
5 # Create a class handle
6 use Class::Handle;
7 my $class = Class::Handle->new( 'Foo::Class' );
8 my $name = $class->name;
9
10 # UNIVERSAL type methods
11 $class->VERSION();
12 $class->isa( 'Foo:Bar' );
13 $class->can( 'blah' );
14
15 # Class::Inspector type methods
16 $class->installed();
17 $class->loaded();
18 $class->filename();
19 $class->resolved_filename();
20 $class->functions();
21 $class->function_refs();
22 $class->function_exists( 'function' );
23 $class->methods( 'public', 'full' );
24 $class->subclasses();
25
26 # Class::ISA type methods
27 $class->super_path();
28 $class->self_and_super_path();
29 $class->full_super_path();
30
31 # Loading and unloading
32 $class->load();
33
34 DESCRIPTION
35 Class related functionality in Perl is broken up into a variety of
36 different modules. Class::Handle attempts to provide a convenient object
37 wrapper around the various different types of functions that can be
38 performed on a class.
39
40 Please note that this is an initial non-production quality release, and
41 should be used as such. Functionality and API are subject to change
42 without notice.
43
44 Currently, Class::Handle provies what is effectively a combined API from
45 "UNIVERSAL", "Class::ISA" and "Class::Inspector" for obtaining
46 information about a Class, and some additional task methods, such as
47 "load" to common tasks relating to classes.
48
49 UNIVERSAL API
50 To ensure we maintain compliance with other classes that rely on methods
51 provided by "UNIVERSAL", Class::Handle acts in the normal way when
52 something like "<Class::Handle-"VERSION>> is called. That is, it returns
53 the version of Class::Handle itself. When "UNIVERSAL" methods are called
54 on an instantiation the method is changed to act on the class we have a
55 handle to. For example, the two following statements are equivalent.
56
57 # Getting the version directly
58 print Foo::Bar->VERSION;
59
60 # Getting the version via Class::Handle
61 my $class = Class::Handle->new( 'Foo::Bar' );
62 print $class->VERSION;
63
64 This also applies to the "isa" and "can" methods.
65
66 METHODS
67 new $class
68 The "new" constructor will create a new handle to a class or unknown
69 existance or status. That is, it won't check that the class actually
70 exists at this time. It WILL however check to make sure that your class
71 name is legal.
72
73 Returns a new Class::Handle object on success
74 Returns undef if the class name is illegal
75
76 name
77 The c<name> method returns the name of the class as original specified
78 in the constructor.
79
80 VERSION
81 Find the version for the class. Does not check that the class is loaded
82 ( at this time ).
83
84 Returns the version on success, "undef" if the class does not defined a
85 $VERSION or the class is not loaded.
86
87 isa $class
88 Checks to see if the class is a subclass of another class. Does not
89 check that the class is loaded ( at this time ).
90
91 Returns true/false as for "UNIVERSAL::isa"
92
93 can $method
94 Checks to see if a particular method is defined for the class.
95
96 Returns a "CODE" ref to the function is the method is available, or
97 false if the class does not have that method available.
98
99 installed
100 Checks to see if a particular class is installed on the machine, or at
101 least that the class is available to perl. In this case, "class" really
102 means "module". This methods cannot detect a class that is not a module.
103 ( Has its own file ).
104
105 Returns true if the class is installed and available, or false
106 otherwise.
107
108 loaded
109 Checks to see if a class is loaded. In this case, "class" does NOT mean
110 "module". The "loaded" method will return true for classes that do not
111 have their own file.
112
113 For example, if a module "Foo" contains the classes "Foo", "Foo::Bar"
114 and "Foo::Buffy", the "loaded" method will return true for all of the
115 classes.
116
117 Returns true if the class is loaded, or false otherwise.
118
119 filename
120 Returns the base filename for a class. For example, for the class
121 "Foo::Bar", "loaded" would return "Foo/Bar.pm".
122
123 The "filename" method is platform neutral, it should always return the
124 filename in the correct format for your platform.
125
126 resolved_filename @extra_paths
127 The "resolved_filename" will attempt to find the real file on your
128 system that will be used when a class is loaded. If additional paths are
129 provided as argument, they will be tried first, before the contents of
130 the @INC array. If a file cannot be found to match the class, returns
131 false.
132
133 loaded_filename
134 If the class is loaded, returns the name of the file that it was
135 originally loaded from.
136
137 Returns false if the class is not loaded, or did not have its own file.
138
139 functions
140 Returns a list of the names of all the functions in the classes
141 immediate namespace. Note that this is not the METHODS of the class,
142 just the functions. Returns a reference to an array of the function
143 names on success.
144
145 Returns undef on error or if the class is not loaded.
146
147 function_refs
148 Returns a list of references to all the functions in the classes
149 immediate namespace.
150
151 Returns a reference to an array of CODE refs of the functions on
152 success, or "undef" on error or if the class is not loaded.
153
154 function_exists $function
155 Checks to see if the function exists in the class. Note that this is as
156 a function, not as a method. To see if a method exists for a class, use
157 the "can" method in UNIVERSAL, and hence to every other class.
158
159 Returns true if the function exists, false if the function does not
160 exist, or "undef" on error, or if the class is not loaded.
161
162 methods @options
163 Attempts to find the methods available to the class. This includes
164 everything in the classes super path up to, but NOT including,
165 UNIVERSAL. Returns a reference to an array of the names of all the
166 available methods on success. Returns undef if the class is not loaded.
167
168 Any provided options are passed through, and alter the response in the
169 same way as for the options to "<Class::Inspector-"methods()>>, that is,
170 'public', 'private', 'full' and 'expanded', and combinations thereof.
171
172 subclasses
173 The "subclasses" method will search then entire namespace (and thus all
174 currently loaded classes) to find all of the subclasses of the class
175 handle.
176
177 The actual test will be done by calling "isa" on the class as a static
178 method. (i.e. "<My::Class-"isa($class)>>.
179
180 Returns a reference to a list of the names of the loaded classes that
181 match the class provided, or false is none match, or "undef" if the
182 class name provided is invalid.
183
184 super_path
185 The "super_path" method is a straight pass through to the
186 "Class::ISA::super_path" function. Returns an ordered list of class
187 names, with no duplicates. The list does NOT include the class itself,
188 or the UNIVERSAL class.
189
190 self_and_super_path
191 As above, but includes ourself at the beginning of the path. Directly
192 passes through to Class::ISA.
193
194 full_super_path
195 The "full_super_path" method is an additional method not in
196 "Class::ISA". It returns as for "super_path", except that it also
197 contains BOTH the class itself, and "UNIVERSAL". This full list is more
198 technically accurate, but less commonly used, and as such isn't
199 available from Class::ISA itself.
200
201 BUGS
202 No known bugs. Additional feature requests are being taken.
203
204 SUPPORT
205 Bugs should be reported via the CPAN bug tracking system
206
207 <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Class-Handle>
208
209 For other inquiries, contact the author
210
211 AUTHOR
212 Adam Kennedy <[email protected]>, <http://ali.as/>
213
214 SEE ALSO
215 "UNIVERSAL", "Class::ISA", and "Class::Inspector", which provide most of
216 the functionality for this class.
217
218 COPYRIGHT
219 Copyright (c) 2002 - 2006 Adam Kennedy.
220
221 This program is free software; you can redistribute it and/or modify it
222 under the same terms as Perl itself.
223
224 The full text of the license can be found in the LICENSE file included
225 with this module.
226