Test-NoOverride
view release on metacpan or search on metacpan
lib/Test/NoOverride.pm view on Meta::CPAN
for my $parent_klass (@parents) {
my @functions = _get_functions($parent_klass);
for my $func (@functions) {
push @{$methods}, { $parent_klass => $func };
}
}
}
if ( scalar @parents ) {
_isa_list($methods, @parents);
}
}
sub _get_functions {
my $package = shift;
my @functions = get_public_functions($package);
{
no strict 'refs'; ## no critic
my %class = %{"${package}::"};
while (my ($k, $v) = each %class) {
push @functions, $k if $k =~ /^_.+/;
}
}
return @functions;
}
1;
__END__
=head1 NAME
Test::NoOverride - stop accidentally overriding
=head1 SYNOPSIS
use Test::NoOverride;
no_override('Some::Class');
no_override(
'Some::Class',
exclude => [qw/ method /], # methods which you override specifically.
);
no_override(
'Some::Class',
exclude_overridden => [qw/ Foo::Bar::method /], # ignore to be overridden.
);
=head1 DESCRIPTION
No more accidentally overriding.
Note that private method (like '_foo') and (import|BEGIN|UNITCHECK|CHECK|INIT|END) methods are ignored (means that these are not checked). Moreover, C<new> method is ignored by default. If you would like to check overriding 'new' method, then you sho...
no_override(
'Some::Class',
new => 1, # The 'new' method will be checked.
);
=head1 REPOSITORY
Test::NoOverride is hosted on github: L<http://github.com/bayashi/Test-NoOverride>
Welcome your patches and issues :D
=head1 AUTHOR
Dai Okabayashi E<lt>bayashi@cpan.orgE<gt>
=head1 SEE ALSO
L<Module::Functions>
=head1 LICENSE
This module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself. See L<perlartistic>.
=cut
( run in 1.821 second using v1.01-cache-2.11-cpan-99c4e6809bf )