Don't use $_ as loop variable when calling arbitrary code (RT#81072)
[gitmo/Moo.git] / t / lib / MooObjectWithDelegate.pm
1 package MooObjectWithDelegate;
2 use ClassicObject;
3 use Scalar::Util ();
4 use Moo;
5
6 has 'delegated' => (
7   is => 'ro',
8   isa => sub {
9     do { $_[0] && Scalar::Util::blessed($_[0]) }
10       or die "Not an Object!";
11   },
12   lazy => 1,
13   builder => '_build_delegated',
14   handles => [qw/connect/],
15 );
16
17 sub _build_delegated {
18   my $self = shift;
19   return ClassicObject->new;
20 }
21
22 around 'connect', sub {
23   my ($orig, $self, @args) = @_;
24   return $self->$orig(@args) . 'b';
25 };
26
27
28 1;