Say I have a class: My::Foo::Bar which inherits from My::Foo, calling My::Foo::Bar->can('a_method') will return true whether a_method is defined in My::Foo::Bar or My::Foo - is there a way to differentate between the two? In other words can I find out not only if a class "can" a method, but also that it's not inherited?
A bit of background on why I need this: I have a set of Class::DBI classes all inheriting from a base class and all defined for the same table. In the base class I have an init() which looks at a specific field and reblesses itself to one of the inheriting classes depending on the value. At this point, I want to call the init() on the newly reblessed reference, only if it defines one (obviously bad things happen if it doesn't).
Sure, there are dozens of trivial workarounds, but this is about learning things, right? :)
Thanks,
PS Sorry if something similar has been answered before - for some reason I am having little luck Super Searching for "can"
In reply to inheritance and can by glwtta
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |