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   56512 use 5.008;
  3         9  
2 3     3   17 use strict;
  3         7  
  3         64  
3 3     3   16 use warnings;
  3         7  
  3         145  
4              
5             package MooseX::Final;
6              
7 3     3   1182 use Exporter::Tiny ();
  3         7420  
  3         483  
8              
9             our $AUTHORITY = 'cpan:TOBYINK';
10             our $VERSION = '0.001';
11             our @ISA = qw(Exporter::Tiny);
12             our @EXPORT = qw(assert_final);
13              
14             sub _generate_assert_final {
15 3     3   457 my $me = shift;
16 3         8 my ($name, $args, $globals) = @_;
17            
18             my $final_package = exists($args->{package})
19             ? $args->{package}
20 3 50       15 : $globals->{into};
21 3 50       12 die "cannot bless things into references"
22             if ref $final_package;
23            
24             return sub {
25 4     4   24422 my $class = ref shift;
26 4 100       26 return if $class eq $final_package;
27            
28 2         16 require Carp;
29 2         6 our @CARP_NOT = ($final_package);
30 2         427 Carp::croak(sprintf '%s is final; %s should not inherit from it', $final_package, $class);
31 3         30 };
32             }
33              
34             1;
35              
36             __END__