in reply to Re: Installing chained methods (Hook::*?)
in thread Installing chained methods

Nothing in the Hook:: class namespace does the right thing here (including Class::Hook). Thank you though. All the Hook:: modules assume that the method already exists and I'm looking at it from the other direction - initially the method doesn't exist and the code just installs it somewhat like Exporter.

Oh well - absent any good suggestions (after waiting a while) I'll just write the darn thing and upload it. Thank you for suggesting Hook:: though - that search keyword didn't occur to me.

Replies are listed 'Best First'.
Re^3: Installing chained methods (wrap a stub?)
by Aristotle (Chancellor) on Apr 21, 2003 at 03:55 UTC
    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.

      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.