Name : perl-Class-Fields
| |
Version : 0.204
| Vendor : obs://build_opensuse_org/devel:languages:perl
|
Release : 1.63
| Date : 2024-08-05 19:57:38
|
Group : Development/Libraries/Perl
| Source RPM : perl-Class-Fields-0.204-1.63.src.rpm
|
Size : 0.05 MB
| |
Packager : (none)
| |
Summary : Inspect the fields of a class
|
Description :
*NOTE* This module, and the fields system, is largely obsolete. Please consider using one of the many accessor generating modules, or just skip directly to a complete object oriented system like Moose or Mouse.
A collection of utility functions/methods for examining the data members of a class. It provides a nice, high-level interface that should stand the test of time and Perl upgrades nicely.
The functions in this module also serve double-duty as methods and can be used that way by having your module inherit from it. For example:
package Foo; use base qw( Class::Fields ); use fields qw( this that _whatever );
print \"\'_whatever\' is a private data member of \'Foo\'\" if Foo->is_private(\'_whatever\');
$obj = Foo->new; print \"\'this\' is a public data member of \'Foo\'\" if $obj->is_public(\'this\');
* *is_field*
is_field($class, $field); $class->is_field($field);
Simply asks if a given $class has the given $field defined in it.
* *is_public*
* *is_private*
* *is_protected*
* *is_inherited*
is_public($class, $field); is_private($class, $field); ...etc... or $obj->is_public($field); or Class->is_public($field);
A bunch of functions to quickly check if a given $field in a given $class is of a given type. For example...
package Foo; use public qw( Ford ); use private qw( _Nixon );
package Bar; use base qw(Foo);
print \'Ford is public\' if is_public(\'Bar\', \'Ford\'); print \'_Nixon is inherited\' if is_inherited(\'Foo\', \'_Nixon\');
* *show_fields*
AATTall_fields = show_fields($class); AATTfields = show_fields($class, AATTattribs); or AATTall_fields = $obj->show_fields; AATTfields = $obj->show_fields(AATTattribs); or AATTall_fields = Class->show_fields; AATTfields = Class->show_fields(AATTattribs);
This will list all fields in a given $class that have the given set of AATTattribs. If AATTattribs is not given it will simply list all fields.
The currently available attributes are: Public, Private, Protected and Inherited
For example:
package Foo; use fields qw(this that meme);
package Bar; use Class::Fields; use base qw(Foo); use fields qw(salmon);
AATTfields = show_fields(\'Bar\', qw(Public Inherited));
* *field_attrib_mask*
$attrib = field_attrib_mask($class, $field); or $attrib = $obj->field_attrib_mask($field); or $attrib = Class->field_attrib_mask($field);
It will tell you the numeric attribute for the given $field in the given $class. $attrib is a bitmask which must be interpreted with the PUBLIC, PRIVATE, etc... constants from Class::Fields::Attrib.
field_attribs() is probably easier to work with in general.
* *field_attribs*
AATTattribs = field_attribs($class, $field); or AATTattribs = $obj->field_attribs($field); or AATTattribs = Class->field_attribs($field);
Exactly the same as field_attrib_mask(), except that instead of returning a bitmask it returns a somewhat friendlier list of attributes which are applied to this field. For example...
package Foo; use fields qw( yarrow );
package Bar; use base qw(Foo);
AATTattribs = field_attribs(\'Bar\', \'yarrow\');
The attributes returned are the same as those taken by show_fields().
* *dump_all_attribs*
dump_all_attribs; dump_all_attribs(AATTclasses); or Class->dump_all_attribs; or $obj->dump_all_attribs;
A debugging tool which simply prints to STDERR everything it can about a given set of AATTclasses in a relatively formated manner.
Alas, this function works slightly differently if used as a function as opposed to a method:
When called as a function it will print out attribute information about all AATTclasses given. If no AATTclasses are given it will print out the attributes of -every- class it can find that has attributes.
When uses as a method, it will print out attribute information for the class or object which uses the method. No arguments are accepted.
I\'m not entirely happy about this split and I might change it in the future.
|
RPM found in directory: /packages/linux-pbone/ftp5.gwdg.de/pub/opensuse/repositories/devel:/languages:/perl:/CPAN-C/openSUSE_Tumbleweed/noarch |