I would find this useful. Perhaps something autogenerated might do, such as a thing which follows the dependencies and generates a list for a given class like RT::Group
along the lines of
RT::Group directly provides:
SelfDescription
Load
ID
…
RT::Group inherits:
RT::Record::_Init
RT::Record::_PrimaryKeys
…
RT::Base::CurrentUser
…
and so on. Then you’d be able to see at a glance what methods will be available for a given class, and where they’ve come from.
(Edit)
Here is a quick and dirty attempt, based on this post: reflection - How do I loop over all the methods of a class in Perl? - Stack Overflow
#!/usr/bin/perl
#
# Report the methods provided by a class and its parents; takes the class
# name as a parameter. Omits methods from ancestors which the descendants
# have overridden.
#
sub ListClassMethods {
my ( $Class, $Prefix, $SeenClasses, $SeenMethods ) = @_;
$Prefix = '' if ( not defined $Prefix );
$SeenClasses = {} if ( not defined $SeenClasses );
$SeenMethods = {} if ( not defined $SeenMethods );
return () if ( exists $SeenClasses->{$Class} );
$SeenClasses->{$Class} = 1;
eval "require $Class";
no strict 'refs';
my @Methods = (
'<li>From <code>' . $Class . '</code><ul>',
(
map { '<li><code>' . $_ . '</code></li>' } sort { $a cmp $b }
map { $SeenMethods->{$_} = 1; $Prefix . $_ }
grep { not exists $SeenMethods->{$_} }
grep { defined &{ $Class . "::$_" } } keys %{ $Class . '::' }
),
'</ul>'
);
push @Methods, ListClassMethods( $_, $_ . '::', $SeenClasses, $SeenMethods )
foreach @{ $Class . '::ISA' };
return @Methods;
}
print '<ul>' . join( "\n", ListClassMethods( $ARGV[0] ) ) . "</ul>\n";
This gives you something like this:
- From
RT::Group
AddMember
AddRight
AvailableRights
BasicColumns
…
- From
RT::Record
RT::Record::ACLEquivalenceObjects
RT::Record::AddAttribute
RT::Record::AddCustomFieldDefaultValues
…
It might be more useful to just dump out the methods of each class horizontally, with this script instead:
#!/usr/bin/perl
#
# Report the methods provided by a class and its parents; takes the class
# name as a parameter. Omits methods from ancestors which the descendants
# have overridden. Shows a short version of the information.
#
sub ListClassMethods {
my ( $Class, $SeenClasses, $SeenMethods ) = @_;
$SeenClasses = {} if ( not defined $SeenClasses );
$SeenMethods = {} if ( not defined $SeenMethods );
return () if ( exists $SeenClasses->{$Class} );
$SeenClasses->{$Class} = 1;
eval "require $Class";
no strict 'refs';
my @Methods = (
'<li><code>' . $Class . '</code>: <br />',
map { '<code>' . $_ . '</code>' } sort { $a cmp $b }
map { $SeenMethods->{$_} = 1; $_ }
grep { not exists $SeenMethods->{$_} }
grep { defined &{ $Class . "::$_" } } keys %{ $Class . '::' }
);
push @Methods, '<ul>',
ListClassMethods( $_, $SeenClasses, $SeenMethods ), '</ul>'
foreach @{ $Class . '::ISA' };
push @Methods, '</li>';
return @Methods;
}
print '<ul>' . join( "\n", ListClassMethods( $ARGV[0] ) ) . "</ul>\n";
This second version gives output like this, which gives an easier quick view of the methods available:
RT::Group
:
AddMember
AddRight
AvailableRights
BasicColumns
BeforeWipeout
Create
CreateRoleGroup
CreateUserDefinedGroup
CurrentUserCanSee
DOES
DeepMembersObj
Delete
DeleteMember
Disabled
…
RT::Record
:
ACLEquivalenceObjects
AddAttribute
AddCustomFieldDefaultValues
AddCustomFieldValue
AllDependedOnBy
AllDependsOn
Attachments
Attributes
ClassifyTransaction
ClearAttributes
ColumnMapClassName
CreatedAsString
…
Hopefully either of these might be useful in this context with a bit of tidying up.