laziness, impatience, and hubris | |
PerlMonks |
Re^2: object method questionby Zarathustra (Beadle) |
on Oct 11, 2005 at 06:42 UTC ( [id://499044]=note: print w/replies, xml ) | Need Help?? |
> I can feel that you are a little bit confused.
>
This exact sort of thing is a breeze in ruby. I say that with good humor! Unfortunately it's difficult to summarize precisely why I need to do what I'm trying to do here - the best I can do is explain _what_ I need...: It's important for me to be able to inject a custom method ( "dbq" ) into an object of an external class ( "DBI" ) which has been instantiated as an attribute ( "_dbh" ) of a custom base class ( "Foo" ). How do I do so? That is what I would like to do - if possible. >$db->dbq("whateverquery"); That's fine for client code that directly instantiates an object of the class in question ( "Foo.pm", "DB.pm", whatever ). One may rightly ask: "So why not just pass the '$foo'/'$db' object itself to those legacy modules?" Because the "$db"/"$foo" class is much, much more than a simple, specialized/dedicated piece of functionality, such as your example. Passing a large object with a bunch of unrelated methods/attributes to another object that simply wants access to one specific method is serious, ugly overkill which I'm hoping to avoid - the very sort of thing why it's all being refactored/rewritten in the first place. In other words, I'm trying to trick the old code into just using the new stuff without a care or any suspicion that something has changed. I'm working with a semi-largish codebase, alot of which relies on receiving an object w/ a particular method, "dbq" in this instance. We're talking some 140+ perl scripts and shoddy modules that all rely on using/recieving this old '$dbh->dbq' thing. I've done some major refactoring and have written some decent oop libraries to replace the existing mess with something more sane; however we simply don't have the time to re-write/re-factor every one of those 140+ scripts/modules at the moment. Thanks for your time, it's difficult to communicate/discuss the nature of the problem without way too much verbosity and code!
In Section
Seekers of Perl Wisdom
|
|