X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=blobdiff_plain;f=lib%2FMouse%2FMeta%2FClass.pm;h=b9179eb09e43e395135782bbca0df980ff690221;hp=5ee9049c463e782e3c93c3c124c46ff7c80783e6;hb=abfdffe0146e788b3b808398fb075231163c3948;hpb=6a1d1835c5d0080e789c2c4c91d50aef0c2a15da diff --git a/lib/Mouse/Meta/Class.pm b/lib/Mouse/Meta/Class.pm index 5ee9049..b9179eb 100644 --- a/lib/Mouse/Meta/Class.pm +++ b/lib/Mouse/Meta/Class.pm @@ -69,18 +69,31 @@ sub add_method { } # copied from Class::Inspector -sub get_method_list { +my $get_methods_for_class = sub { my $self = shift; - my $name = $self->name; + my $name = shift; no strict 'refs'; # Get all the CODE symbol table entries my @functions = - grep !/^(?:has|with|around|before|after|blessed|extends|confess)$/, + grep !/^(?:has|with|around|before|after|blessed|extends|confess|override|super)$/, grep { defined &{"${name}::$_"} } keys %{"${name}::"}; - push @functions, keys %{$self->{'methods'}->{$name}}; + push @functions, keys %{$self->{'methods'}->{$name}} if $self; wantarray ? @functions : \@functions; +}; + +sub get_method_list { + my $self = shift; + $get_methods_for_class->($self, $self->name); +} + +sub get_all_method_names { + my $self = shift; + my %uniq; + return grep { $uniq{$_}++ == 0 } + map { $get_methods_for_class->(undef, $_) } + $self->linearized_isa; } sub add_attribute { @@ -160,6 +173,10 @@ sub make_immutable { if ($args{inline_destructor}) { $self->add_method('DESTROY' => Mouse::Meta::Method::Destructor->generate_destructor_method_inline( $self )); } + + # Moose's make_immutable returns true allowing calling code to skip setting an explicit true value + # at the end of a source file. + return 1; } sub make_mutable { confess "Mouse does not currently support 'make_mutable'" } @@ -178,8 +195,7 @@ sub _install_modifier { $code ); } - else { - require Class::Method::Modifiers; + elsif (eval "require Class::Method::Modifiers; 1") { Class::Method::Modifiers::_install_modifier( $into, $type, @@ -187,6 +203,9 @@ sub _install_modifier { $code ); } + else { + Carp::croak("Method modifiers require the use of Class::Method::Modifiers. Please install it from CPAN and file a bug report with this application."); + } } sub add_before_method_modifier {