RRP/Entity.pm

filter: Statementstmt 44.0% 11 / 25 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 33.3% 3 / 9 Podpod 100% 6 / 6 totaltotal 47.6% 20 / 42 CC 2 SCAR 9.2
CC
2
Cov
41%
getAttribute
6.0
new
2.0
getName
2.0
CRAP 2.5
« RRP/Request/Describe.pm ↑ Summary RRP/Entity/Contact.pm »
1 package Net::RRP::Entity;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Net::RRP::Exception::MissingRequiredAttribute;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Net::RRP::Toolkit;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 $Net::RRP::Entity::VERSION = '0.02';
8  
9 =head1 NAME
10  
11 Net::RRP::Entity - rrp entity abstraction class
12  
13 =head1 SYNOPSIS
14  
15 use Net::RRP::Entity;
16 my $entity = new Net::RRP::Entity();
17  
18 =head1 DESCRIPTION
19  
20 This is a base class for all Entity::* classes.
21  
22 =cut
23  
24 =head2 new
25  
26 This is a constructor. Example:
27  
28 use Net::RRP::Entity;
29 my $entity = new Net::RRP::Entity();
30 my $entity1 = new Net::RRP::Entity( key => [ 'value' ] );
31  
32 =cut
33  
34 sub new
35 0 ▶{
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
36 0 my $class = shift;
37 0 bless { attributes => Net::RRP::Toolkit::lowerKeys ( { @_ } ) }, $class;
38 }
39  
40 =head2 getName
41  
42 Return a *real* name of this entity. You must overwrite this method at child class. Example:
43  
44 my $entityName = $entity->getName();
45 print STDERR "EntityName is $entityName\n";
46  
47 =cut
48  
49 sub getName
50 0 ▶{
Subroutine getName: not called CC=1 SCAR=6.9
Pod documented
51 0 die "Must be implemented at child class";
52 }
53  
54 =head2 setAttribute
55  
56 Setup attribte with name $attributeName to a $attributeValue. $attributeValue must be a array ref. Example:
57  
58 $entity->setAttribute ( $attributeName, $attributeValue );
59 $entity->setAttribute ( 'DomainName', [ 'test.ru' ] );
60 $entity->setAttribute ( 'NameServer', [ 'ns1.ttt.ru', 'ns2.qqq.ru' ] );
61  
62 =cut
63  
64 sub setAttribute
65 0 ▶{
Subroutine setAttribute: not called CC=1 SCAR=6.9
Pod documented
66 0 my ( $this, $attributeName, $attributeValue ) = @_;
67 0 $attributeName = lc ( $attributeName );
68 0 my $old = $this->{attributes}->{$attributeName};
69 0 $this->{attributes}->{$attributeName} = $attributeValue;
70 0 $old;
71 }
72  
73 =head2 getAttribute
74  
75 Return a value of $attributeName attribute. Example:
76  
77 print STDERR $entity->getAttribute ( 'NameServer' )->[ 0 ];
78  
79 Can throw Net::RRP::Exception::MissingRequiredAttribute exception
80  
81 =cut
82  
83 sub getAttribute
84 0 ▶{
Subroutine getAttribute: not called CC=2 SCAR=17.9
Pod documented
85 0 my ( $this, $attributeName ) = @_;
86 0 ▶ $this->{attributes}->{ lc ( $attributeName ) } || throw Net::RRP::Exception::MissingRequiredAttribute();
Branch: 1 branch
BranchTrueFalseTotal
$this->{"attributes"}{lc $attributeName} or "Net::RRP::Exception::MissingRequiredAttribute"->throw 0 0 0
87 }
88  
89 =head2 getAttributes
90  
91 Return the hash ref of the all entity attributes. Example:
92  
93 my $attributes = $entity->getAttributes();
94 foreach my $attributeName ( keys %$attributes )
95 {
96 print $attributeName . ' ' . $attributes->{ $$attributeName }->[ 0 ];
97 }
98  
99 =cut
100  
101 sub getAttributes
102 0 ▶{
Subroutine getAttributes: not called CC=1 SCAR=6.9
Pod documented
103 0 my $this = shift;
104 0 $this->{attributes};
105 }
106  
107 =head2 getPrimaryAttributeValue
108  
109 return a "primary" attribute value
110  
111 =cut
112  
113 sub getPrimaryAttributeValue
114 0 ▶{
Subroutine getPrimaryAttributeValue: not called CC=1 SCAR=6.9
Pod documented
115 0 my $this = shift;
116 0 $this->getAttribute ( $this->getName . 'Name' );
117 }
118  
119 1 1;
120  
121 =head1 AUTHOR AND COPYRIGHT
122  
123 Net::RRP::Entity (C) Michael Kulakov, Zenon N.S.P. 2000
124 125124, 19, 1-st Jamskogo polja st,
125 Moscow, Russian Federation
126  
127 mkul@cpan.org
128  
129 All rights reserved.
130  
131 You may distribute this package under the terms of either the GNU
132 General Public License or the Artistic License, as specified in the
133 Perl README file.
134  
135 =head1 SEE ALSO
136  
137 L<Net::RRP::Request(3)>, L<Net::RRP::Response(3)>, L<Net::RRP::Codec(3)>, RFC 2832,
138 L<Net::RRP::Exception::MissingRequiredAttribute(3)>
139  
140 =cut
141  
142 __END__
« RRP/Request/Describe.pm ↑ Summary RRP/Entity/Contact.pm »