[OT] Wrapping methods

Daniel Ruoso daniel at ruoso.com
Mon Jul 6 20:17:37 BST 2009


Em Seg, 2009-07-06 às 17:06 +0100, Nicholas Clark escreveu:
> Sorry to mention the 4 letter word...
> I'm not sure if there is a good answer to this, but:
> Say I have a system of interchangeable components defined by
>    @ISA = 'Generic::Base::Class';
>    sub run { ... }
> such that it's invoked to do its work as $object->run(...);
> Is there any not-insanely-hacky way to conjure up a wrapper class
> Generic::Base::ClassWithTimeout
> such that a component could be written as 
>    @ISA = 'Generic::Base::ClassWithTimeout';
>    sub run { ... }
> called, as ever, as $object->run(...);

As it was already pointed out, Moose provides you the tools to do that,
but the most sane way to do that is by using a metaclass, that will
allow you to use method modifiers, as you can see in
add_around_method_modifier.

http://search.cpan.org/~drolsky/Class-MOP-0.89/lib/Class/MOP/Class.pm#Method_Modifiers

daniel



More information about the london.pm mailing list