in reply to Re: Re: Installing chained methods
in thread Installing chained methods

Aha, I see. Maybe like so?
use Hook::WrapSubs; do { no strict 'refs'; *{"GreenPartyDB::Database::${table}::${hook}"} = sub {}; } unless UNIVERSAL::can("GreenPartyDB::Database::${table}", $hook) wrap_subs( "GreenPartyDB::Database::${table}::${hook}", UNIVERSAL::can(__PACKAGE__."::${prefix}", $hook), );
Note that using UNIVERSAL::can() will respect inherited methods, which is not unlikely to be better than what you started out with (or may be not, of course - your call).

Makeshifts last the longest.

Replies are listed 'Best First'.
Re: Re^3: Installing chained methods (wrap a stub?)
by diotalevi (Canon) on Apr 22, 2003 at 03:36 UTC

    What do you think of calling it 'Class::AppendMethods'?

      So you're rolling your own after all?

      I don't know if AppendMethods is very descriptive.. append to what? To the class? To an object? I could mean a number of things other than what you intend.

      I don't have an idea for a better name right now either though.

      Makeshifts last the longest.

        Yeah, DrManhattan also suggested having an insert_method() function (I think its better named prepend_method) which sort of blows the whole ::AppendMethods name out of the water. Maybe something will come to me over lunch. I'd call it multi-methods but that's a different concept.

        Maybe Class::ChainedMethods? That name isn't clear to me either but its another idea.