Fix ton of buggery with defer-immutable accessor shim
[p5sagit/Class-Accessor-Grouped.git] / t / lib / AccessorGroups.pm
CommitLineData
e7d391a8 1package AccessorGroups;
2use strict;
3use warnings;
5808b224 4use base 'AccessorGroupsParent';
5
6__PACKAGE__->mk_group_accessors('simple', [ fieldname_torture => join ('', reverse map { chr($_) } (0..255) ) ]);
e7d391a8 7
fee7c68b 8sub get_simple {
9 my $v = shift->SUPER::get_simple (@_);
10 $v =~ s/ Extra tackled on$// if $v;
11 $v;
12}
13
14sub set_simple {
15 my ($self, $f, $v) = @_;
16 $v .= ' Extra tackled on' if $f eq 'singlefield';
17 $self->SUPER::set_simple ($f, $v);
18 $_[2];
19}
20
de167379 21# a runtime Class::Method::Modifiers style around
22# the eval/our combo is so that we do not need to rely on Sub::Name being available
23my $orig_ra_cref = __PACKAGE__->can('runtime_around');
24our $around_cref = sub {
25 my $self = shift;
26 if (@_) {
27 my $val = shift;
28 $self->$orig_ra_cref($val . ' Extra tackled on');
29 $val;
30 }
31 else {
32 my $val = $self->$orig_ra_cref;
33 $val =~ s/ Extra tackled on$// if defined $val;
34 $val;
35 }
36};
37{
38 no warnings qw/redefine/;
39 eval <<'EOE';
5808b224 40 sub runtime_around { goto $around_cref };
41 sub _runtime_around_accessor { goto $around_cref };
de167379 42EOE
43}
44
e7d391a8 451;