Re: Getting class of accessor

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

From: Tony Bowden
Subject: Re: Getting class of accessor
Date: 11:15 on 05 Feb 2005
On Fri, Feb 04, 2005 at 06:27:31PM -0800, Peter Speltz wrote:
> package Class::Farm;
> __PACKAGE__->has_a ('toad' => "Class::Toad");
> __PACKAGE__->has_many ('mules' => "Class::Mule");
> Is there a one liner or sub in Class::DBI to get the class of toad or mules
> without knowing what relationship they are part of? 

Not easily. Class::DBI doesn't always know what you're going to get
back. But in the simplest cases something like this might do:

  my $meta = $class->meta_info;
  my ($isa) = map $_->foreign_class, grep defined, 
    map $meta->{$_}->{$name}, keys %$meta;

Tony


Getting class of accessor
Peter Speltz 02:27 on 05 Feb 2005

Re: Getting class of accessor
Tony Bowden 11:15 on 05 Feb 2005

Generated at 17:31 on 15 Feb 2005 by mariachi v0.52