2 package AccessorGroups::BeenThereDoneThat;
6 use base 'Class::Accessor::Grouped';
8 __PACKAGE__->mk_group_accessors('simple', 'singlefield');
9 __PACKAGE__->mk_group_accessors('multiple', qw/multiple1 multiple2/);
13 package AccessorGroups;
16 use base 'Class::Accessor::Grouped';
17 __PACKAGE__->mk_group_accessors('simple', 'singlefield');
18 __PACKAGE__->mk_group_accessors('multiple', qw/multiple1 multiple2/);
19 __PACKAGE__->mk_group_accessors('listref', [qw/lr1name lr1;field/], [qw/lr2name lr2'field/]);
20 __PACKAGE__->mk_group_accessors('simple', 'runtime_around');
21 __PACKAGE__->mk_group_accessors('simple', [ fieldname_torture => join ('', map { chr($_) } (0..255) ) ]);
24 my $v = shift->SUPER::get_simple (@_);
25 $v =~ s/ Extra tackled on$// if $v;
30 my ($self, $f, $v) = @_;
31 $v .= ' Extra tackled on' if $f eq 'singlefield';
32 $self->SUPER::set_simple ($f, $v);
36 # a runtime Class::Method::Modifiers style around
37 # the eval/our combo is so that we do not need to rely on Sub::Name being available
38 my $orig_ra_cref = __PACKAGE__->can('runtime_around');
39 our $around_cref = sub {
43 $self->$orig_ra_cref($val . ' Extra tackled on');
47 my $val = $self->$orig_ra_cref;
48 $val =~ s/ Extra tackled on$// if defined $val;
53 no warnings qw/redefine/;
55 sub AccessorGroups::runtime_around { goto $AccessorGroups::around_cref };
56 sub AccessorGroups::_runtime_around_accessor { goto $AccessorGroups::around_cref };
61 return bless {}, shift;
64 foreach (qw/multiple listref/) {
66 *{"get_$_"} = __PACKAGE__->can('get_simple');
67 *{"set_$_"} = __PACKAGE__->can('set_simple');