Commit | Line | Data |
e7d391a8 |
1 | package AccessorGroups; |
2 | use strict; |
3 | use warnings; |
4 | use base 'Class::Accessor::Grouped'; |
5 | |
9540f4e4 |
6 | __PACKAGE__->mk_group_accessors('simple', 'singlefield'); |
28344104 |
7 | __PACKAGE__->mk_group_accessors('multiple', qw/multiple1 multiple2/); |
8 | __PACKAGE__->mk_group_accessors('listref', [qw/lr1name lr1;field/], [qw/lr2name lr2'field/]); |
e7d391a8 |
9 | |
fee7c68b |
10 | sub get_simple { |
11 | my $v = shift->SUPER::get_simple (@_); |
12 | $v =~ s/ Extra tackled on$// if $v; |
13 | $v; |
14 | } |
15 | |
16 | sub set_simple { |
17 | my ($self, $f, $v) = @_; |
18 | $v .= ' Extra tackled on' if $f eq 'singlefield'; |
19 | $self->SUPER::set_simple ($f, $v); |
20 | $_[2]; |
21 | } |
22 | |
e7d391a8 |
23 | sub new { |
24 | return bless {}, shift; |
25 | }; |
26 | |
28344104 |
27 | foreach (qw/multiple listref/) { |
28 | no strict 'refs'; |
29 | *{"get_$_"} = __PACKAGE__->can('get_simple'); |
30 | *{"set_$_"} = __PACKAGE__->can('set_simple'); |
31 | }; |
32 | |
e7d391a8 |
33 | 1; |