Query: class::field
OS: debian
Section: 3pm
Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar
Class::Field(3pm) User Contributed Perl Documentation Class::Field(3pm)NAMEClass::Field - Class Field Accessor GeneratorSYNOPSISpackage 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;DESCRIPTIONClass::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.FUNCTIONSo 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.NOTEThis code was taken directly out the Spiffy module for those people who just want this functionality without using the rest of Spiffy.AUTHORIngy dA~Xt Net <ingy@cpan.org>COPYRIGHTCopyright (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)
Related Man Pages |
---|
mail::field::generic5.18(3) - mojave |
mail::field::generic(3) - osx |
mail::field::date5.18(3) - mojave |
class::accessor::class(3pm) - debian |
plucene::document::field(3pm) - debian |
Similar Topics in the Unix Linux Community |
---|
can't get perl Class::Struct to work |
Cut last Field |
Problem updated file with new entries |
Replace a data in a field if that does not contain a particular pattern |
Field Substitution |