X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Flib%2FAccessorGroups.pm;h=1d70e57351c84f8a84c6634360048aa7a4ea18d0;hb=5808b2245979b6d4c0582c10892e8526aa00d673;hp=0fb5a7c6810c11718b766a35e8b96d57a40e6122;hpb=8ef9b3ff970550236c6846c7d446e3bf09ae0a66;p=p5sagit%2FClass-Accessor-Grouped.git diff --git a/t/lib/AccessorGroups.pm b/t/lib/AccessorGroups.pm index 0fb5a7c..1d70e57 100644 --- a/t/lib/AccessorGroups.pm +++ b/t/lib/AccessorGroups.pm @@ -1,15 +1,45 @@ package AccessorGroups; use strict; use warnings; -use base 'Class::Accessor::Grouped'; +use base 'AccessorGroupsParent'; -__PACKAGE__->mk_group_accessors('simple', 'singlefield'); -__PACKAGE__->mk_group_accessors('simple', qw/multiple1 multiple2/); -__PACKAGE__->mk_group_accessors('simple', [qw/lr1name lr1;field/], [qw/lr2name lr2'field/]); -__PACKAGE__->mk_group_accessors('component_class', 'result_class'); +__PACKAGE__->mk_group_accessors('simple', [ fieldname_torture => join ('', reverse map { chr($_) } (0..255) ) ]); -sub new { - return bless {}, shift; +sub get_simple { + my $v = shift->SUPER::get_simple (@_); + $v =~ s/ Extra tackled on$// if $v; + $v; +} + +sub set_simple { + my ($self, $f, $v) = @_; + $v .= ' Extra tackled on' if $f eq 'singlefield'; + $self->SUPER::set_simple ($f, $v); + $_[2]; +} + +# a runtime Class::Method::Modifiers style around +# the eval/our combo is so that we do not need to rely on Sub::Name being available +my $orig_ra_cref = __PACKAGE__->can('runtime_around'); +our $around_cref = sub { + my $self = shift; + if (@_) { + my $val = shift; + $self->$orig_ra_cref($val . ' Extra tackled on'); + $val; + } + else { + my $val = $self->$orig_ra_cref; + $val =~ s/ Extra tackled on$// if defined $val; + $val; + } }; +{ + no warnings qw/redefine/; + eval <<'EOE'; + sub runtime_around { goto $around_cref }; + sub _runtime_around_accessor { goto $around_cref }; +EOE +} 1;