Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Listing the functions of a package / methods of an object

by stvn (Monsignor)
on Jul 15, 2008 at 18:22 UTC ( #697772=note: print w/replies, xml ) Need Help??


in reply to Listing the functions of a package / methods of an object

This will work with any Plain Old Perl Package, no Moose-ness required.

my @methods = Class::MOP::Class->initialize('Class::Name')->compute_al +l_applicable_methods;
Each element of @methods will be a HASH ref containing
  • method name
  • the name of the class in which the method lives
  • a Class::MOP::Method instance that contains the CODE ref for the actual method
As with your version (and pretty much any introspection out there) it will not handle AUTOLOAD (IMO - AUTOLOAD is evil anyway, it shouldn't be used and any modules that use it should be treated with suspicion). It will also properly ignore imported functions as well, like if you were to import Scalar::Util::blessed into your package, Class::MOP::Class would properly ignore it since it is not a method.

-stvn

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://697772]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (9)
As of 2018-07-17 12:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (363 votes). Check out past polls.

    Notices?