I think handles is the clearest and most flexible way to let method calls go through. I use it often when wrapping up objects into an ad hoc API.
use 5.14.0; use strictures; package SomeMangagedObject { use Moo; sub exterminate { 1 } sub Exterminate { 10 } sub EXTERMINATE { 100 } 1; }; package MyWrApper { use Moo; use Scalar::Util "blessed"; use Carp; has "robot" => is => "ro", required => 1, handles => [qw/ exterminate Exterminate EXTERMINATE /], default => sub { SomeMangagedObject->new }, isa => sub { "SomeMangagedObject" eq blessed $_[0] or confess "Nope" }; 1; }; my $wrap = MyWrApper->new; say $wrap->robot; say $wrap->exterminate;
In reply to Re: Using AUTOLOAD with Moo
by Your Mother
in thread Using AUTOLOAD with Moo
by nysus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |