Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

class::accessor::class(3pm) [debian man page]

Class::Accessor::Class(3pm)				User Contributed Perl Documentation			       Class::Accessor::Class(3pm)

NAME
Class::Accessor::Class - simple class variable accessors VERSION
version 0.501 $Id: /my/cs/projects/claccl/trunk/lib/Class/Accessor/Class.pm 27922 2006-11-13T16:05:47.533928Z rjbs $ SYNOPSIS
Set up a module with class accessors: package Text::Fortune; use base qw(Class::Accessor::Class Exporter); Robot->mk_class_accessors(qw(language offensive collection)); sub fortune { if (__PACKAGE__->offensive) { .. Then, when using the module: use Text::Fortune; Text::Fortune->offensive(1); print fortune; # prints an offensive fortune Text::Fortune->language('EO'); print fortune; # prints an offensive fortune in Esperanto DESCRIPTION
Class::Accessor::Class provides a simple way to create accessor and mutator methods for class variables, just as Class::Accessor provides for objects. It can use either an enclosed lexical variable, or a package variable. This module was once implemented in terms of Class::Accessor, but changes to that module broke this relationship. Class::Accessor::Class is still a subclass of Class::Accessor, strictly for historical reasons. As a side benefit, a class that isa Class::Accessor::Class is also a Class::Accessor and can use its methods. METHODS
mk_class_accessors package Foo; use base qw(Class::Accessor::Class); Foo->mk_class_accessors(qw(foo bar baz)); Foo->foo(10); my $obj = new Foo; print $obj->foo; # 10 This method adds accessors for the named class variables. The accessor will get or set a lexical variable to which the accessor is the only access. mk_package_accessors package Foo; use base qw(Class::Accessor::Class); Foo->mk_package_accessors(qw(foo bar baz)); Foo->foo(10); my $obj = new Foo; print $obj->foo; # 10 print $Foo::foo; # 10 This method adds accessors for the named class variables. The accessor will get or set the named variable in the package's symbol table. DETAILS
make_class_accessor $accessor = Class->make_class_accessor($field); This method generates a subroutine reference which acts as an accessor for the named field. make_package_accessor $accessor = Class->make_package_accessor($field); This method generates a subroutine reference which acts as an accessor for the named field, which is stored in the scalar named "field" in "Class"'s symbol table. This can be useful for dealing with legacy code, but using package variables is almost never a good idea for new code. Use this with care. AUTHOR
Ricardo SIGNES, "<rjbs@cpan.org>" BUGS
Please report any bugs or feature requests to "bug-class-accessor-class@rt.cpan.org", or through the web interface at <http://rt.cpan.org>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. COPYRIGHT
Copyright 2004-2006 Ricardo Signes, All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.12.3 2006-11-13 Class::Accessor::Class(3pm)

Check Out this Related Man Page

Class::Field(3pm)					User Contributed Perl Documentation					 Class::Field(3pm)

NAME
Class::Field - Class Field Accessor Generator SYNOPSIS
package Thing; use Class::Field qw'field const'; field 'this'; field 'list' => []; field 'map' => {}; field 'that', -init => '$self->setup_that'; field 'circular_ref' => -weaken; const 'answer' => 42; DESCRIPTION
Class::Field exports two subroutines, "field" and "const". These functions are used to declare fields and constants in your class. Class::Field generates custom code for each accessor that is optimized for speed. FUNCTIONS
o field Defines accessor methods for a field of your class: package Example; use base 'Parent'; use Class::Field qw'field const'; field 'foo'; field bar => []; sub lalala { my $self = shift; $self->foo(42); push @{$self->{bar}}, $self->foo; } The first parameter passed to "field" is the name of the attribute being defined. Accessors can be given an optional default value. This value will be returned if no value for the field has been set in the object. o const const bar => 42; The "const" function is similar to <field> except that it is immutable. It also does not store data in the object. You probably always want to give a "const" a default value, otherwise the generated method will be somewhat useless. NOTE
This code was taken directly out the Spiffy module for those people who just want this functionality without using the rest of Spiffy. AUTHOR
Ingy dA~Xt Net <ingy@cpan.org> COPYRIGHT
Copyright (c) 2006, 2008, 2009. Ingy dA~Xt Net. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See <http://www.perl.com/perl/misc/Artistic.html> perl v5.10.1 2009-12-10 Class::Field(3pm)
Man Page