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
On Tue, Sep 8, 2009 at 7:46 PM, mega...@gmail.com wrote:
Yuri
Are you doing this in order to effect duck-typing? If so, you may want to
consider applying the attributes with a Role, and using this idiom:
if ($obj-does('fooer')) {}
Or there is the duck_type helper in
Excerpts from Yuri Shtil's message of Tue Sep 08 19:26:57 -0400 2009:
What is the right way to see if an object has certain attribute?
if (Moose::Util::find_meta($obj)-find_attribute_by_name(foo)) {
do some stuff
}
I almost never find myself wanting this, though (except when writing
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
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?
--
Yuri
Just FYI, I suggest usingTry::Tiny instead of plain eval.
On Sep 8, 2009, at 8:07 PM, Yuri Shtil wrote:
Hans Dieter Pearcey wrote:
Excerpts from Yuri Shtil's message of Tue Sep 08 19:26:57 -0400 2009:
What is the right way to see if an object has certain attribute?
if
Hans Dieter Pearcey wrote:
Excerpts from Yuri Shtil's message of Tue Sep 08 19:26:57 -0400 2009:
What is the right way to see if an object has certain attribute?
if (Moose::Util::find_meta($obj)-find_attribute_by_name(foo)) {
do some stuff
}
I almost never find myself wanting