I'm pretty sure I've made a bad design decision but not sure what else I can do with Moo. I want a attribute to handle methods if they don't exist:
package Mac::ApperlScript::App::Finder::Window ; use Moo; use Mac::AppleScript::Glue::Object; use namespace::autoclean; our $AUTOLOAD; has 'obj' => (is => 'ro', required => 1, isa => sub { die 'Improper object passed' unless ref $_[0] eq 'Mac::AppleScript::Glue::Object' }, writer => '_set_obj', ); sub AUTOLOAD { my $s = shift; my @al = split /::/, $AUTOLOAD; my $method = $al[-1]; return $s->obj->$method; }
So I delegate all methods that don't exist to the obj attribute. The problem is that methods like DESTROY seem to get diverted to the AUTOLOAD subroutine. Is there a better way to achieve what I want to do?
$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest Vicar";
$nysus = $PM . ' ' . $MCF;
Click here if you love Perl Monks
In reply to Using AUTOLOAD with Moo by nysus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |