| 1 | package EO::Data; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 3 | ▶ | use EO; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 3 | ▶ | use NEXT; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 3 | ▶ | use Scalar::Util qw(weaken); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | 3 | ▶ | use EO::Hash; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | #use EO::Locale; | ||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 3 | our $VERSION = 0.96; | |||||||||||||||||||
| 13 | 3 | our @ISA = qw(EO); | |||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 3 | exception EO::Error::InvalidParameter; | |||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 1 | ▶ | sub init { | ||||||||||||||||||
|
Subroutine
init: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||
| 18 | 1 | my $self = shift; | |||||||||||||||||||
| 19 | 1 | my $string = ''; | |||||||||||||||||||
| 20 | 1 | ▶ | if ($self->NEXT::init( @_ )) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 21 | 1 | $self->{e_data_content} = \$string; | |||||||||||||||||||
| 22 | 1 | $self->{e_data_storage} = {}; | |||||||||||||||||||
| 23 | 1 | return 1; | |||||||||||||||||||
| 24 | } | ||||||||||||||||||||
| 25 | 0 | return 0; | |||||||||||||||||||
| 26 | } | ||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | 0 | ▶ | sub length { | ||||||||||||||||||
|
Subroutine
length: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 29 | 0 | my $self = shift; | |||||||||||||||||||
| 30 | 0 | return length( $self->content ); | |||||||||||||||||||
| 31 | } | ||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | 0 | ▶ | sub locales { | ||||||||||||||||||
|
Subroutine
locales: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 34 | 0 | my $self = shift; | |||||||||||||||||||
| 35 | 0 | ▶ | if (@_) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 36 | 0 | $self->{ e_data_locales} = shift; | |||||||||||||||||||
| 37 | 0 | return $self; | |||||||||||||||||||
| 38 | } | ||||||||||||||||||||
| 39 | 0 | return $self->{ e_data_locales }; | |||||||||||||||||||
| 40 | } | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | 0 | ▶ | sub locale { | ||||||||||||||||||
|
Subroutine
locale: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 43 | 0 | my $self = shift; | |||||||||||||||||||
| 44 | 0 | ▶ | if (@_) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 45 | 0 | $self->{ e_data_locale } = shift; | |||||||||||||||||||
| 46 | 0 | return $self; | |||||||||||||||||||
| 47 | } | ||||||||||||||||||||
| 48 | 0 | return $self->{ e_data_locale }; | |||||||||||||||||||
| 49 | } | ||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | 0 | ▶ | sub delete_storage { | ||||||||||||||||||
|
Subroutine
delete_storage: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 52 | 0 | my $self = shift; | |||||||||||||||||||
| 53 | 0 | my $storage = shift; | |||||||||||||||||||
| 54 | 0 | ▶ | if (!UNIVERSAL::isa($storage, 'EO::Storage')) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 55 | 0 | throw EO::Error::InvalidParameter | |||||||||||||||||||
| 56 | text => 'storage must be an EO::Storage object'; | ||||||||||||||||||||
| 57 | } | ||||||||||||||||||||
| 58 | 0 | delete($self->{e_data_storage}->{$storage}); | |||||||||||||||||||
| 59 | 0 | return $self; | |||||||||||||||||||
| 60 | } | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | |||||||||||||||||||||
| 63 | 0 | ▶ | sub add_storage { | ||||||||||||||||||
|
Subroutine
add_storage: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 64 | 0 | my $self = shift; | |||||||||||||||||||
| 65 | 0 | my $storage = shift; | |||||||||||||||||||
| 66 | 0 | ▶ | if (!UNIVERSAL::isa($storage, 'EO::Storage')) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 67 | 0 | throw EO::Error::InvalidParameter | |||||||||||||||||||
| 68 | text => 'storage must be an EO::Storage object'; | ||||||||||||||||||||
| 69 | } | ||||||||||||||||||||
| 70 | 0 | $self->{e_data_storage}->{$storage} = $storage; | |||||||||||||||||||
| 71 | 0 | weaken($self->{e_data_storage}->{$storage}); | |||||||||||||||||||
| 72 | 0 | return $self; | |||||||||||||||||||
| 73 | } | ||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | 0 | ▶ | sub storage { | ||||||||||||||||||
|
Subroutine
storage: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||
| 76 | 0 | my $self = shift; | |||||||||||||||||||
| 77 | 0 | ▶ | if(@_) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 78 | 0 | my $storage = shift; | |||||||||||||||||||
| 79 | 0 | ▶ | if (!UNIVERSAL::isa($storage, 'EO::Storage')) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 80 | 0 | throw EO::Error::InvalidParameter | |||||||||||||||||||
| 81 | text => 'storage must be an EO::Storage object'; | ||||||||||||||||||||
| 82 | } | ||||||||||||||||||||
| 83 | 0 | $self->{e_data_storage} = { $storage => $storage }; | |||||||||||||||||||
| 84 | 0 | weaken( $self->{e_data_storage}->{ $storage } ); | |||||||||||||||||||
| 85 | 0 | return $self; | |||||||||||||||||||
| 86 | } | ||||||||||||||||||||
| 87 | 0 | return values %{$self->{e_data_storage}}; | |||||||||||||||||||
| 88 | } | ||||||||||||||||||||
| 89 | |||||||||||||||||||||
| 90 | 0 | ▶ | sub content { | ||||||||||||||||||
|
Subroutine
content: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||
| 91 | 0 | my $self = shift; | |||||||||||||||||||
| 92 | 0 | ▶ | if(@_) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 93 | 0 | my $content = shift; | |||||||||||||||||||
| 94 | 0 | ▶ | if(ref($content) eq 'SCALAR') { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 95 | 0 | $self->{e_data_content} = $content; | |||||||||||||||||||
| 96 | ▶ | } elsif(ref($content) && $content->isa('EO::Data')) { | |||||||||||||||||||
|
Condition0%0/3
ref $content and $content->isa("EO::Data")
MC/DC0%0/2
ref $content and $content->isa("EO::Data")
ref $content
$content->isa("EO::Data")
Truth table0%0/3
A and B
A= ref $contentB= $content->isa("EO::Data")
| |||||||||||||||||||||
| 97 | 0 | $self->content($content->content_ref); | |||||||||||||||||||
| 98 | } else { | ||||||||||||||||||||
| 99 | 0 | ${$self->{e_data_content}} = $content; | |||||||||||||||||||
| 100 | } | ||||||||||||||||||||
| 101 | 0 | return $self; | |||||||||||||||||||
| 102 | } | ||||||||||||||||||||
| 103 | 0 | return ${$self->{e_data_content}}; | |||||||||||||||||||
| 104 | } | ||||||||||||||||||||
| 105 | |||||||||||||||||||||
| 106 | 0 | ▶ | sub save { | ||||||||||||||||||
|
Subroutine
save: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 107 | 0 | my $self = shift; | |||||||||||||||||||
| 108 | 0 | foreach my $storage (values %{$self->{e_data_storage}}) { | |||||||||||||||||||
| 109 | 0 | $storage->save($self); | |||||||||||||||||||
| 110 | } | ||||||||||||||||||||
| 111 | 0 | return $self; | |||||||||||||||||||
| 112 | } | ||||||||||||||||||||
| 113 | |||||||||||||||||||||
| 114 | 0 | ▶ | sub content_ref { | ||||||||||||||||||
|
Subroutine
content_ref: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 115 | 0 | my $self = shift; | |||||||||||||||||||
| 116 | 0 | return $self->{e_data_content}; | |||||||||||||||||||
| 117 | } | ||||||||||||||||||||
| 118 | |||||||||||||||||||||
| 119 | 3 | 1; | |||||||||||||||||||
| 120 | |||||||||||||||||||||
| 121 | __END__ | ||||||||||||||||||||