File Coverage

blib/lib/Code/Crypt/Graveyard.pm
Criterion Covered Total %
statement 15 15 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod 1 1 100.0
total 22 22 100.0


line stmt bran cond sub pod time code
1             package Code::Crypt::Graveyard;
2             {
3             $Code::Crypt::Graveyard::VERSION = '0.001000';
4             }
5              
6             # ABSTRACT: Encrypt you code with multiple nested keys
7              
8 1     1   688 use Moo;
  1         3  
  1         6  
9              
10             has code => (
11             is => 'ro',
12             required => 1,
13             );
14              
15             has builders => (
16             is => 'ro',
17             required => 1,
18             );
19              
20 4     4   24 sub _builder_at { $_[0]->builders->[$_[1]] }
21 1     1   5 sub _innermost_builder { $_[0]->_builder_at(0) }
22 1     1   5 sub _outermost_builder { $_[0]->_builder_at($_[0]->_final_builder_index) }
23 2     2   4 sub _final_builder_index { scalar @{$_[0]->builders} - 1 }
  2         10  
24              
25             sub final_code {
26 1     1 1 2377 my $self = shift;
27              
28 1         3 $self->_innermost_builder->code($self->code);
29              
30 1         3 for my $builder_id (1 .. $self->_final_builder_index) {
31 1         3 my $builder = $self->_builder_at($builder_id);
32 1         3 my $wrapped_builder = $self->_builder_at($builder_id - 1);
33 1         5 $builder->code($wrapped_builder->final_code);
34             }
35             $self->_outermost_builder->final_code
36 1         1277 }
37              
38             1;
39              
40             __END__