}
# 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 {
sub make_immutable {
my $self = shift;
- my %args = @_;
+ my %args = (
+ inline_constructor => 1,
+ @_,
+ );
+
my $name = $self->name;
$self->{is_immutable}++;
- $self->add_method('new' => Mouse::Meta::Method::Constructor->generate_constructor_method_inline( $self ));
+
+ if ($args{inline_constructor}) {
+ $self->add_method('new' => Mouse::Meta::Method::Constructor->generate_constructor_method_inline( $self ));
+ }
+
if ($args{inline_destructor}) {
$self->add_method('DESTROY' => Mouse::Meta::Method::Destructor->generate_destructor_method_inline( $self ));
}
sub attribute_metaclass { "Mouse::Meta::Class" }
-sub _install_fast_modifier {
- my $self = shift;
- my $into = shift;
- my $type = shift;
- my $modifier = pop;
-
- foreach my $name (@_) {
- my $method = Data::Util::get_code_ref( $into, $name );
-
- if ( !$method || !Data::Util::subroutine_modifier($method) ) {
-
- unless ($method) {
- $method = $into->can($name)
- or confess "The method '$name' is not found in the inheritance hierarchy for class $into";
- }
- $method = Data::Util::modify_subroutine( $method,
- $type => [$modifier] );
-
- no warnings 'redefine';
- Data::Util::install_subroutine( $into, $name => $method );
- }
- else {
- Data::Util::subroutine_modifier( $method, $type => $modifier );
- }
- }
- return;
-}
-
sub _install_modifier {
my ( $self, $into, $type, $name, $code ) = @_;
- if (eval "require Data::Util; 1") {
- $self->_install_fast_modifier(
+ if (eval "require Class::Method::Modifiers::Fast; 1") {
+ Class::Method::Modifiers::Fast::_install_modifier(
$into,
$type,
$name,