replacing a method of a Moose object at runtime
Posted
by xxxxxxx
on Stack Overflow
See other posts from Stack Overflow
or by xxxxxxx
Published on 2010-03-12T18:13:07Z
Indexed on
2010/03/12
18:17 UTC
Read the original article
Hit count: 634
Hi, is it possible to replace a method of a Moose object at runtime ? By looking at the source code of Class::MOP::Method(which Moose::Meta::Method inherits from) I concluded that by doing
$method->{body} = sub{ my stuff }
I would be able to replace at runtime a method of an object. I can get the method using
$object->meta->find_method_by_name(<method_name>);
However.. this didn't quite work out.
Is it conceivable to modify methods at runtime ? and what is the way to do it with Moose ?
Thanks
© Stack Overflow or respective owner