Entity.pm

filter: Statementstmt 52.9% 9 / 17 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 2 / 4 Podpod 100% 2 / 2 totaltotal 48.1% 13 / 27 CC 3 SCAR 14.7
CC
3
Cov
43%
get
6.0
set
6.0
BEGIN
1.0
CRAP 4.3
« Client.pm ↑ Summary
1 # Licensed to the Apache Software Foundation (ASF) under one or more
2 # contributor license agreements. See the NOTICE file distributed with
3 # this work for additional information regarding copyright ownership.
4 # The ASF licenses this file to You under the Apache License, Version 2.0
5 # (the "License"); you may not use this file except in compliance with
6 # the License. You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15  
16 package Usergrid::Entity;
17  
18 10 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 10 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 =head1 NAME
22  
23 Usergrid::Entity - a Usergrid entity
24  
25 =head1 DESCRIPTION
26  
27 Encapsulates Usergrid entities and provides methods for accessing the underlying
28 data.
29  
30 =head1 ATTRIBUTES
31  
32 =over 4
33  
34 =item object
35  
36 A hash reference with the entity data
37  
38 =back
39  
40 =cut
41 10 has 'object' => ( is => 'rw', required => 1);
42  
43 =head1 METHODS
44  
45 =over 4
46  
47 =item get ( $attribute_name )
48  
49 Returns the value of the specified attribute.
50  
51 =cut
52 0 ▶sub get {
Subroutine get: not called CC=2 SCAR=17.9
Pod documented
53 0 my ($self, $key) = @_;
54 0 ▶ return $self->object->{$key} if (defined $self->object->{$key});
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->object->{$key} 0 0 0
55 0 return $self->object->{'entities'}[0]->{$key};
56 }
57  
58 =item set ( $attribute_name, $value )
59  
60 Sets the value of the specified attribute.
61  
62 =cut
63 0 ▶sub set {
Subroutine set: not called CC=2 SCAR=17.9
Pod documented
64 0 my ($self, $key, $value) = @_;
65 0 ▶ if (defined $self->object->{$key}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->object->{$key}) 0 0 0
66 0 $self->object->{$key} = $value;
67 0 return;
68 }
69 0 $self->object->{'entities'}[0]->{$key} = $value;
70 }
71  
72 10 __PACKAGE__->meta->make_immutable;
73  
74 10 1;
75  
76 __END__
« Client.pm ↑ Summary