Jesse Luehrs wrote:
On Tue, Sep 08, 2009 at 04:26:57PM -0700, Yuri Shtil wrote:
What is the right way to see if an object has certain attribute?

I tried
if $obj->can('foo')  {}

but got burned when something like 'import/export' gets in a way.
Do I have to maintain the list of attributes (an another attribute !!!) as I create them?

$obj->meta->has_attribute('foo')

Reading through the Class::MOP docs is helpful in finding out how to
access all of the class definition information that gets stored.

-doy
Sorry for reopening an old subject.
This does not work if the attribute is inherited.

--

Yuri

Reply via email to