File Coverage

blib/lib/Data/Object/Prototype/Instance.pm
Criterion Covered Total %
statement 11 26 42.3
branch 0 12 0.0
condition 1 12 8.3
subroutine 4 5 80.0
pod 0 1 0.0
total 16 56 28.5


line stmt bran cond sub pod time code
1             # Data::Object::Prototype Instance Class
2             package Data::Object::Prototype::Instance;
3              
4 1     1   6 use Moo ();
  1         1  
  1         20  
5 1     1   4 use Moo::Role ();
  1         1  
  1         146  
6              
7             our $VERSION = '0.02'; # VERSION
8              
9             *package = sub {
10 5     5   673 require Data::Object::Prototype::Package;
11 5   33     108 return Data::Object::Prototype::Package->new(
12             name => ref($_[0]) || $_[0]
13             )
14             };
15              
16             my $c = 0;
17             my $m = 0;
18             sub DEMOLISH {
19 0     0 0   my $self = shift;
20 0   0       my $class = ref($self) || $self;
21              
22             # nasty business all the way down
23 0 0 0       $INC{'Class/MOP.pm'} and $c++ if !$c;
24 0 0         Class::MOP::remove_metaclass_by_name($class) if $c;
25 0 0 0       $INC{'Moo.pm'} and $m++ if !$m;
26 0 0         delete $Moo::MAKERS{$class} if $m;
27              
28 0 0         unless ($class eq __PACKAGE__) {
29 1     1   4 no strict 'refs';
  1         2  
  1         158  
30 0           my $table = "${class}::";
31 0           my %symbols = %$table;
32 0           for my $symbol (keys %symbols) {
33 0 0         next if $symbol =~ /\A[^:]+::\z/;
34 0           delete $symbols{$symbol};
35             }
36 0           my $file = join('/', split('::', $class)) . 'pm';
37 0           delete $INC{$file};
38             }
39              
40 0           return 1;
41             }
42              
43             1;