Web/Page/Data.pm

filter: Statementstmt 100% 17 / 17 Branchbran 100% 6 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 2 / 2 Podpod 100% 1 / 1 totaltotal 100% 26 / 26 CC 6 SCAR 16.7
CC
6
Cov
100%
new
6.0
BEGIN
1.0
CRAP 5.3
« Web/Site.pm ↑ Summary Web/Request.pm »
1 package EntityModel::Web::Page::Data;
2 {
3 10 $EntityModel::Web::Page::Data::VERSION = '0.004';
4 }
5 10 ▶use EntityModel::Class {
Subroutine BEGIN: called CC=1 SCAR=0.0
6 10 key => { type => 'string' },
7 value => { type => 'string' },
8 class => { type => 'string' },
9 instance => { type => 'string' },
10 method => { type => 'string' },
11 data => { type => 'string' },
12 parameter => { type => 'array', subclass => 'EntityModel::Web::Page::Data' },
13 10 };
14  
15 =pod
16  
17 Accepts the following items:
18  
19 =over 4
20  
21 =item * key - the name to assign to this data value
22  
23 =item * value - static value to assign
24  
25 =item * class - a class to call a method on
26  
27 =item * instance - an instance on which to call the given method
28  
29 =item * method - a method to call
30  
31 =item * data - an existing data item
32  
33 =item * param - parameters to pass to the method
34  
35 =back
36  
37 =cut
38  
39 10 ▶sub new {
Subroutine new: called CC=6 SCAR=17.9
Pod documented
40 10 my $class = shift;
41 10 my $self = bless {}, $class;
42 10 ▶ my %args = ref $_[0] ? %{$_[0]} : @_;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 6 4 10
43  
44 10 foreach my $item (qw(key value class method instance data)) {
45 60 ▶ if(defined(my $v = delete $args{$item})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $v = delete $args{$item})) 20 40 60
46 20 $self->$item($v);
47 }
48 }
49  
50 # Recurse for any defined parameters
51 10 ▶ if(defined(my $param = delete $args{parameter})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $param = delete $args{"parameter"})) 1 9 10
52 1 foreach my $p (@$param) {
53 4 $self->parameter->push(
54 EntityModel::Web::Page::Data->new(%$p)
55 );
56 }
57 }
58 10 return $self;
59 }
60  
61 10 1;
62  
« Web/Site.pm ↑ Summary Web/Request.pm »