blib/lib/Tie/Hash/DataSection.pm

filter: Statementstmt 85.7% 12 / 14 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 89.4% 17 / 19 CC 1 SCAR 0.6
CC
1
Cov
86%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
↑ Summary
1 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use 5.020;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use experimental qw( signatures );
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use stable qw( postderef );
Subroutine BEGIN: called CC=1 SCAR=0.0
5 0 ▶use true;
Subroutine BEGIN: called CC=1 SCAR=2.6
6  
7 package Tie::Hash::DataSection 0.01 {
8  
9 # ABSTRACT: Access __DATA__ section via tied hash
10  
11  
12 use Data::Section::Pluggable 0.08;
13 use Ref::Util qw( is_plain_arrayref );
14  
15 sub TIEHASH ($class, $package=undef, @plugins) {
16 $package //= caller;
17 my $dsp = Data::Section::Pluggable->new(
18 package => $package,
19 );
20 foreach my $plugin (@plugins) {
21 if(is_plain_arrayref $plugin) {
22 my($name, @args) = @$plugin;
23 $dsp->add_plugin($name => @args);
24 } else {
25 $dsp->add_plugin($plugin);
26 }
27 }
28 return bless [$dsp], $class;
29 }
30  
31 sub FETCH ($self, $key) {
32 return $self->[0]->get_data_section($key);
33 }
34  
35 sub EXISTS ($self, $key) {
36 exists $self->[0]->get_data_section->{$key};
37 }
38  
39 sub FIRSTKEY ($self) {
40 $self->[1] = [keys $self->[0]->get_data_section->%*];
41 return $self->NEXTKEY;
42 }
43  
44 sub NEXTKEY ($self, $=undef) {
45 return shift $self->[1]->@*;
46 }
47  
48 sub STORE ($self, $, $) {
49 require Carp;
50 Carp::croak("hash is read-only");
51 }
52  
53 sub DELETE ($self, $) {
54 require Carp;
55 Carp::croak("hash is read-only");
56 }
57  
58 sub CLEAR ($self) {
59 require Carp;
60 Carp::croak("hash is read-only");
61 }
62 }
63  
64 __END__
↑ Summary