[Moose-commits] r7568 - in Class-MOP/trunk: . lib/Class/MOP t
sartak at code2.0beta.co.uk
sartak at code2.0beta.co.uk
Thu Feb 5 21:11:13 GMT 2009
Author: sartak
Date: 2009-02-05 13:11:13 -0800 (Thu, 05 Feb 2009)
New Revision: 7568
Modified:
Class-MOP/trunk/Changes
Class-MOP/trunk/lib/Class/MOP/Class.pm
Class-MOP/trunk/t/010_self_introspection.t
Log:
Add get_all_method_names
Modified: Class-MOP/trunk/Changes
===================================================================
--- Class-MOP/trunk/Changes 2009-02-05 17:11:56 UTC (rev 7567)
+++ Class-MOP/trunk/Changes 2009-02-05 21:11:13 UTC (rev 7568)
@@ -18,6 +18,8 @@
* Tests
- Add test showing how the xs Class::MOP::is_class_loaded can
be made to operate differently to the pure perl version (t0m)
+ * Class::MOP::Class
+ - Add get_all_method_names (Sartak)
0.75 Wed, December 31, 2008
* Class::MOP::Class
Modified: Class-MOP/trunk/lib/Class/MOP/Class.pm
===================================================================
--- Class-MOP/trunk/lib/Class/MOP/Class.pm 2009-02-05 17:11:56 UTC (rev 7567)
+++ Class-MOP/trunk/lib/Class/MOP/Class.pm 2009-02-05 21:11:13 UTC (rev 7568)
@@ -800,6 +800,12 @@
} shift->get_all_methods(@_);
}
+sub get_all_method_names {
+ my $self = shift;
+ my %uniq;
+ grep { $uniq{$_}++ == 0 } map { $_->name } $self->get_all_methods;
+}
+
sub find_all_methods_by_name {
my ($self, $method_name) = @_;
(defined $method_name && $method_name)
@@ -1100,6 +1106,7 @@
class_precedence_list => 'ARRAY',
linearized_isa => 'ARRAY', # FIXME perl 5.10 memoizes this on its own, no need?
get_all_methods => 'ARRAY',
+ get_all_method_names => 'ARRAY',
#get_all_attributes => 'ARRAY', # it's an alias, no need, but maybe in the future
compute_all_applicable_attributes => 'ARRAY',
get_meta_instance => 'SCALAR',
@@ -1555,6 +1562,12 @@
Use L<get_all_methods>, which is easier/better/faster. This method predates
L<Class::MOP::Method>.
+=item B<get_all_method_names>
+
+This will traverse the inheritance heirachy and return a list of all the
+applicable method names for this class. Duplicate names are removed, but the
+order the methods come out is not defined.
+
=item B<find_all_methods_by_name ($method_name)>
This will traverse the inheritence hierarchy and locate all methods
Modified: Class-MOP/trunk/t/010_self_introspection.t
===================================================================
--- Class-MOP/trunk/t/010_self_introspection.t 2009-02-05 17:11:56 UTC (rev 7567)
+++ Class-MOP/trunk/t/010_self_introspection.t 2009-02-05 21:11:13 UTC (rev 7568)
@@ -1,7 +1,7 @@
use strict;
use warnings;
-use Test::More tests => 234;
+use Test::More tests => 236;
use Test::Exception;
use Class::MOP;
@@ -71,7 +71,7 @@
superclasses subclasses class_precedence_list linearized_isa
has_method get_method add_method remove_method alias_method wrap_method_body
- get_method_list get_method_map get_all_methods compute_all_applicable_methods
+ get_method_list get_method_map get_all_method_names get_all_methods compute_all_applicable_methods
find_method_by_name find_all_methods_by_name find_next_method_by_name
add_before_method_modifier add_after_method_modifier add_around_method_modifier
More information about the Moose-commits
mailing list