Re: getting all method names

[prev] [thread] [next] [Date index for 2005/04/05]

From: William Ross
Subject: Re: getting all method names
Date: 08:26 on 05 Apr 2005
On 5 Apr 2005, at 05:03, mlambrichs@xxxxxxxxxx.xx wrote:

> How can I get a list of all possible attributes/methods of a cdbi 
> class?

$class->columns('All')

will give you the list of attribute names, some of which will be 
columns that inflate to a has_a relationship, but all of which can be 
accessed in the same way, so this will work:

my $object = Model::Object->retrieve( $id );
for ($object->columns('All')){
    do_something( $object->get($_) );
}

If your DTO needs to carry related objects too, you can call

$class->meta_info('has_many');

to get a hashref describing all the has_many relationships of a class 
or object in a form like

{
	{
		accessor => method_name,
		foreign_class => Class::Name,
		...
	},
	...
}

and $class->meta_info('has_a') will do the same for has_a relationships 
if you need to separate those out and treat them differently to plain 
columns.

best

will

getting all method names
mlambrichs 04:03 on 05 Apr 2005

Re: getting all method names
Dana Hudes 04:09 on 05 Apr 2005

Re: getting all method names
Marc Lambrichs 04:27 on 05 Apr 2005

Re: getting all method names
Dana Hudes 04:32 on 05 Apr 2005

Re: getting all method names
Kingsley Kerce 04:50 on 05 Apr 2005

Re: getting all method names
William Ross 08:26 on 05 Apr 2005

Generated at 09:29 on 27 Apr 2005 by mariachi v0.52