I have an object which holds a stack of objects. The object represents the current state, and each object in the stack holds the state at a particular level of nesting.
package State;
use Mouse;
use RealState;
has state_stack => {
is => 'rw',
isa => 'ArrayRef[RealState]',
default => sub {
return [RealState->new]
}
};
I want State to delegate to State->state_stack->[0]. How can I do that efficiently with Mouse (so no meta hacking). I cannot use Moose, my project cannot have any dependencies (I’m bundling Mouse::Tiny).
“You can’t” is fine, I’ll write an AUTOLOAD.
You can’t it directly, but there’s a hack better than AUTOLOAD. That is, RealState->meta->get_all_method_names() gives you method names which are defined in RealState.