Treex/Core/WildAttr.pm

filter: Statementstmt 100% 40 / 40 Branchbran 100% 10 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 100% 3 / 3 totaltotal 100% 62 / 62 CC 6 SCAR 5.4
CC
6
Cov
100%
wild
2.0
_wild_dump
2.0
_set_wild_dump
2.0
CRAP 1.7
« Treex/Core/TredView/BackendStorable.pm ↑ Summary Treex/Core/Common.pm »
1 package Treex::Core::WildAttr;
2 48 $Treex::Core::WildAttr::VERSION = '2.20210102';
3 48 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 48 ▶use Treex::Core::Log;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 48 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 has wild => (
10 is => 'rw',
11  
12 # isa => 'HashRef',
13 reader => '_get_wild',
14 writer => 'set_wild',
15 293 ▶ default => sub { return {} },
Subroutine __ANON__: called CC=1 SCAR=0.0
16 48 );
17  
18 161 ▶sub wild {
Subroutine wild: called CC=2 SCAR=6.9
Pod documented
19 161 my ($self) = @_;
20 161 ▶ if ( !$self->_get_wild ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_get_wild) 10 151 161
21 10 $self->set_wild( {} );
22 }
23 161 return $self->_get_wild;
24  
25 }
26  
27 89 ▶sub _wild_dump {
Subroutine _wild_dump: called CC=2 SCAR=6.9
28 89 my ($self) = @_;
29 89 ▶ if ( $self->isa('Treex::Core::Document') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isa('Treex::Core::Document')) { } 33 56 89
30 33 my $metadata = $self->metaData('pml_root');
31 33 my $meta = $metadata->{meta};
32 33 return $meta->{wild_dump};
33 }
34 else {
35 56 return $self->{wild_dump};
36 }
37 }
38  
39 64 ▶sub _set_wild_dump {
Subroutine _set_wild_dump: called CC=2 SCAR=6.9
40 64 my ( $self, $value ) = @_;
41  
42 64 my $storing_hash_ref = $self;
43 64 ▶ if ( $self->isa('Treex::Core::Document') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isa("Treex::Core::Document")) 10 54 64
44 10 $storing_hash_ref = $self->metaData('pml_root')->{meta};
45 }
46  
47 64 $storing_hash_ref->{wild_dump} = $value;
48 64 return;
49 }
50  
51 64 ▶sub serialize_wild {
Subroutine serialize_wild: called CC=2 SCAR=6.9
Pod documented
52 64 my ($self) = @_;
53 64 ▶ if ( %{ $self->wild } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (%{$self->wild;}) { } 3 61 64
54 3 $self->_set_wild_dump( Dumper( $self->wild ) );
55 }
56 else {
57 61 $self->_set_wild_dump(undef);
58 }
59 64 return;
60 }
61  
62 86 ▶sub deserialize_wild {
Subroutine deserialize_wild: called CC=2 SCAR=6.9
Pod documented
63 86 my ($self) = @_;
64 86 ▶ if ( $self->_wild_dump ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_wild_dump) { } 3 83 86
65 3 $self->set_wild( eval "my " . $self->_wild_dump . '; return $VAR1' ); ## no critic (ProhibitStringyEval)
66 }
67 else {
68 83 $self->set_wild( {} );
69 }
70 86 return;
71 }
72  
73 48 1;
74  
75 __END__
« Treex/Core/TredView/BackendStorable.pm ↑ Summary Treex/Core/Common.pm »