Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Tomcat42
perl-Class-Fields
perl-Class-Fields.spec
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File perl-Class-Fields.spec of Package perl-Class-Fields
# # spec file for package perl-Class-Fields # # Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed # upon. The license for this file, and modifications and additions to the # file, is the same license as for the pristine package itself (unless the # license for the pristine package is not an Open Source License, in which # case the license is the MIT License). An "Open Source License" is a # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. # Please submit bugfixes or comments via http://bugs.opensuse.org/ # Name: perl-Class-Fields Version: 0.204 Release: 0 %define cpan_name Class-Fields Summary: Inspect the fields of a class. License: Artistic-1.0 or GPL-1.0+ Group: Development/Libraries/Perl Url: http://search.cpan.org/dist/Class-Fields/ Source: http://www.cpan.org/authors/id/M/MS/MSCHWERN/%{cpan_name}-%{version}.tar.gz BuildArch: noarch BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: perl BuildRequires: perl-macros BuildRequires: perl(Carp::Assert) Requires: perl(Carp::Assert) %{perl_requires} %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 the Moose manpage or the Mouse manpage. 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'); # Let's assume we have a new() method defined for Foo, okay? $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); # This will print only 'Ford is public' because Ford is a public # field of the class Bar. _Nixon is a private field of the class # Foo, but it is not inherited. print 'Ford is public' if is_public('Bar', 'Ford'); print '_Nixon is inherited' if is_inherited('Foo', '_Nixon'); * *show_fields* @all_fields = show_fields($class); @fields = show_fields($class, @attribs); or @all_fields = $obj->show_fields; @fields = $obj->show_fields(@attribs); or @all_fields = Class->show_fields; @fields = Class->show_fields(@attribs); This will list all fields in a given $class that have the given set of @attribs. If @attribs 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); # @fields contains 'this', 'that' and 'meme' since they are Public and # Inherited. It doesn't contain 'salmon' since while it is # Public it is not Inherited. @fields = 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* @attribs = field_attribs($class, $field); or @attribs = $obj->field_attribs($field); or @attribs = 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); # @attribs will contain 'Public' and 'Inherited' @attribs = 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(@classes); 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 @classes 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 @classes given. If no @classes 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. %prep %setup -q -n %{cpan_name}-%{version} %build %{__perl} Makefile.PL INSTALLDIRS=vendor %{__make} %{?_smp_mflags} %check %{__make} test %install %perl_make_install %perl_process_packlist %perl_gen_filelist %files -f %{name}.files %defattr(-,root,root,755) %doc Changes %changelog
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor