Commit | Line | Data |
e7d391a8 |
1 | package AccessorGroups; |
2 | use strict; |
3 | use warnings; |
5808b224 |
4 | use base 'AccessorGroupsParent'; |
5 | |
6 | __PACKAGE__->mk_group_accessors('simple', [ fieldname_torture => join ('', reverse map { chr($_) } (0..255) ) ]); |
e7d391a8 |
7 | |
fee7c68b |
8 | sub get_simple { |
9 | my $v = shift->SUPER::get_simple (@_); |
10 | $v =~ s/ Extra tackled on$// if $v; |
11 | $v; |
12 | } |
13 | |
14 | sub 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 |
23 | my $orig_ra_cref = __PACKAGE__->can('runtime_around'); |
24 | our $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 |
42 | EOE |
43 | } |
44 | |
e7d391a8 |
45 | 1; |