Maurice,

> It seems some people like inherited stuff
> (including roles) to be listed in each class that inherits stuff and others
> like it only in the class which defines stuff.

It seems to me that the problem with listing methods (and/or
attributes) that you inherit is that, if the base class changes, the
POD for all subclasses then has to change as well.  This sets you up
for having your POD and your code be out of sync, and it's pretty
difficult to maintain, particularly if the same author is not
responsible for both.

I suppose this is midly off-topic from your original question, but I'd
be curious to know how the fans of documenting inherited methods
answer this objection.


            -- Buddy


PS-- Don't get me wrong: if you *don't* document the inherited
methods, it can make it hideously difficult for your users to find the
POD for a given method.  I have this problem all the time with
Class::MOP and Moose itself.  So much so that I wrote the code below.
So it's a bit of a lose-lose proposition, really.

    # find a method in a class hierarchy
    sub whose_method
    {
        my ($classname, $methodname) = @_;
        my $meta = $classname->meta;

        my @results;
        CLASS: foreach ($meta->can('linearized_isa') ? (reverse
$meta->linearized_isa) : ($classname))
        {
            my $meta = $_->meta;

            # check roles of the class before the class itself
            if ($meta->can('calculate_all_roles'))
            {
                foreach ($meta->calculate_all_roles)
                {
                    my %m = map { $_ => 1 } $_->get_method_list;
                    push @results, $_->name and next CLASS if $m{$methodname};
                }
            }

            my %m = map { $_ => 1 } $meta->get_method_list;
            push @results, $_ if $m{$methodname};
        }

        return @results;
    }

I don't expect that's perfect, but it's seemed to work pretty well for
me so far.

Reply via email to