Class::Accessor::Grouped(3) User Contributed Perl Documentation Class::Accessor::Grouped(3)
NAME
Class::Accessor::Grouped - Lets you build groups of accessors
SYNOPSIS
use base 'Class::Accessor::Grouped';
# make basic accessors for objects
__PACKAGE__->mk_group_accessors(simple => qw(id name email));
# make accessor that works for objects and classes
__PACKAGE__->mk_group_accessors(inherited => 'awesome_level');
# make an accessor which calls a custom pair of getters/setters
sub get_column { ... this will be called when you do $obj->name() ... }
sub set_column { ... this will be called when you do $obj->name('foo') ... }
__PACKAGE__->mk_group_accessors(column => 'name');
DESCRIPTION
This class lets you build groups of accessors that will call different getters and setters. The documentation of this module still requires
a lot of work (volunteers welcome >.>), but in the meantime you can refer to this post <http://lo-
f.at/glahn/2009/08/WritingPowerfulAccessorsForPerlClasses.html> for more information.
Notes on accessor names
In general method names in Perl are considered identifiers, and as such need to conform to the identifier specification of
"qr/A[A-Z_a-z][0-9A-Z_a-z]*z/". While it is rather easy to invoke methods with non-standard names ("$obj->${"anything goes"}"), it is
not possible to properly declare such methods without the use of Sub::Name. Since this module must be able to function identically with and
without its optional dependencies, starting with version 0.10008 attempting to declare an accessor with a non-standard name is a fatal
error (such operations would silently succeed since version 0.08004, as long as Sub::Name is present, or otherwise would result in a syntax
error during a string eval).
Unfortunately in the years since 0.08004 a rather large body of code accumulated in the wild that does attempt to declare accessors with
funny names. One notable perpetrator is DBIx::Class::Schema::Loader, which under certain conditions could create accessors of the "column"
group which start with numbers and/or some other punctuation (the proper way would be to declare columns with the "accessor" attribute set
to "undef").
Therefore an escape mechanism is provided via the environment variable "CAG_ILLEGAL_ACCESSOR_NAME_OK". When set to a true value, one
warning is issued per class on attempts to declare an accessor with a non-conforming name, and as long as Sub::Name is available all
accessors will be properly created. Regardless of this setting, accessor names containing nulls "