[rt-devel] plugins and _Vendor files

Thomas Sibley trs at bestpractical.com
Tue Jun 11 12:28:49 EDT 2013


On 06/11/2013 06:02 AM, Ruslan Zakirov wrote:
> In recent code we don't use Hook::LexWrap as it's in most
> case unnecesary. Something close to the following should work just fine:
> 
> require RT::XXX;
> {
>     my $orig = RT::XXX->can("method");
>     *RT::XXX::method = sub {
>         my $self = shift;
>         return $orig->($self, @_);
>     };
> }

My favorite is much the same, with the added benefit that you can die if
the API call is removed.

{
    package RT::Foo;
    no warnings 'redefine';

    my $original = __PACKAGE__->can("bar")
        or die "API change?!  Can't find method 'bar' in ", __PACKAGE__;
    sub bar {
        ...
        $original->(...)
    }
}


More information about the rt-devel mailing list