Is there a sane way to specify a callback to be executed every time a subroutine has finished compiling? The `signatures` pragma currently does this but with XS, which is beyond my hacking abilities. If there is something like an API for hooking into subroutine creation, sugar method keywords could thrigger it too.
-- Peter >________________________________ > From: Jesse Luehrs <d...@tozt.net> >To: Peter Shangov <pshan...@yahoo.com> >Cc: moose <moose@perl.org> >Sent: Wednesday, 11 January 2012, 22:05 >Subject: Re: "automatically" wrapping methods. > >On Wed, Jan 11, 2012 at 01:58:40PM -0800, Peter Shangov wrote: >> Or you can use B::Hooks::EndOfScope to do the wrapping at the end of the >> compilation stage: >> >> # untested code >> package MooseX::MethodValidation; >> use B::Hooks::EndOfScope; >> sub import { >> on_scope_end { >> my $caller = caller; >> my $meta = Moose::Meta::Class->initialize($caller); >> foreach my $method ( $meta->get_all_methods ) { >> ... # wrapping code goes here >> } >> } >> } >> >> package MyModel::User; >> use MooseX::MethodValidation; >> ... # your subs go here > >This actually isn't a great idea, because not all methods are defined at >compile time. If you declare any methods via method modifiers, or >attributes, or any other method declaration sugar, they won't exist when >that validation code runs. > >-doy > > >