package Baz;
use Moo;
sub beep {'beep'}
+
+ sub is_passed_undefined { !defined($_[0]) ? 'bar' : 'fail' }
}
{
eat_curry => [ yum => 'Curry!' ],
});
has foo5 => ( is => 'ro', handles => 'ExtRobot' );
+ has foo6 => ( is => 'rw',
+ handles => { foobot => '${\\Baz->can("beep")}'},
+ default => sub { 0 } );
+ has foo7 => ( is => 'rw',
+ handles => { foobar => '${\\Baz->can("is_passed_undefined")}'},
+ default => sub { undef } );
+
}
my $bar = Bar->new(
is $bar->eat_curry, 'Curry!', 'handles works for currying';
+is $bar->foobot, 'beep', 'asserter checks for existence not truth, on false value';
+
+is $bar->foobar, 'bar', 'asserter checks for existence not truth, on undef ';
+
+{
+ local $@;
+ ok !eval q{
+ package Baz;
+ use Moo;
+ has foo => ( is => 'ro', handles => 'Robot' );
+ sub smash { 1 };
+ 1;
+ }, 'handles will not overwrite locally defined method';
+ like $@, qr{You cannot overwrite a locally defined method \(smash\) with a delegation};
+}
+
done_testing;