File Coverage

blib/lib/MooseX/Final.pm
Criterion Covered Total %
statement 21 21 100.0
branch 4 6 66.6
condition n/a
subroutine 6 6 100.0
pod n/a
total 31 33 93.9


line stmt bran cond sub pod time code
1 3     3   118888 use 5.008;
  3         18  
2 3     3   11 use strict;
  3         5  
  3         60  
3 3     3   11 use warnings;
  3         5  
  3         89  
4              
5             package MooseX::Final;
6              
7 3     3   1078 use Exporter::Tiny ();
  3         6969  
  3         369  
8              
9             our $AUTHORITY = 'cpan:TOBYINK';
10             our $VERSION = '0.002';
11             our @ISA = qw(Exporter::Tiny);
12             our @EXPORT = qw(assert_final);
13              
14             sub _generate_assert_final {
15 3     3   281 my $me = shift;
16 3         5 my ($name, $args, $globals) = @_;
17            
18             my $final_package = exists($args->{package})
19             ? $args->{package}
20 3 50       9 : $globals->{into};
21 3 50       17 die "cannot bless things into references"
22             if ref $final_package;
23            
24             return sub {
25 4     4   18800 my $class = ref shift;
26 4 100       16 return if $class eq $final_package;
27            
28 2         11 require Carp;
29 2         5 our @CARP_NOT = ($final_package);
30 2         343 Carp::croak(sprintf '%s is final; %s should not inherit from it', $final_package, $class);
31 3         21 };
32             }
33              
34             1;
35              
36             __END__