Oterica/Node.pm

filter: Statementstmt 53.3% 16 / 30 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 57.1% 4 / 7 Podpod 100% 3 / 3 totaltotal 46.0% 23 / 50 CC 7 SCAR 23.2
CC
7
Cov
40%
in_node_family
20.0
add_to_family
12.0
as_data_lines
6.0
CRAP 10.2
« Oterica/App.pm ↑ Summary Oterica/Hub.pm »
1 package DNS::Oterica::Node;
2 # ABSTRACT: DNSO node. belongs to families.
3 1 $DNS::Oterica::Node::VERSION = '0.313';
4 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use DNS::Oterica::Role::RecordMaker;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 #pod =head1 OVERVIEW
9 #pod
10 #pod A node is any part of a network, either a domain or a node. It is a member of
11 #pod zero or more families.
12 #pod
13 #pod Like other DNS::Oterica objects, they should be created through the hub.
14 #pod
15 #pod =attr domain
16 #pod
17 #pod This is a string representing the domain's domain name, for example
18 #pod F<example.com>.
19 #pod
20 #pod =cut
21  
22 1 has domain => (is => 'ro', isa => 'Str', required => 1);
23  
24 #pod =attr families
25 #pod
26 #pod This is an arrayref of the families in which the node has been placed.
27 #pod
28 #pod =cut
29  
30 1 ▶has families => (is => 'ro', isa => 'ArrayRef', default => sub { [] });
Subroutine __ANON__: called CC=1 SCAR=0.0
31  
32 #pod =method add_to_family
33 #pod
34 #pod $node->add_to_family($family);
35 #pod
36 #pod This method adds the node to the given family, which may be given either as an
37 #pod object or as a name.
38 #pod
39 #pod If the node is already in the family, nothing happens.
40 #pod
41 #pod =cut
42  
43 sub add_to_family {
44 0 ▶ my ($self, $family) = @_;
Subroutine add_to_family: not called CC=3 SCAR=24.8
Pod documented
45 0 ▶ $family = $self->hub->node_family($family) unless ref $family;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $family 0 0 0
46 0 ▶ return if $self->in_node_family($family);
Branch: 1 branch
BranchTrueFalseTotal
if $self->in_node_family($family) 0 0 0
47 0 $family->add_node($self);
48 0 push @{ $self->families }, $family;
49 }
50  
51 #pod =method in_node_family
52 #pod
53 #pod if ($node->in_node_family($family)) { ... }
54 #pod
55 #pod This method returns true if the node is a member of the named (or passed)
56 #pod family and false otherwise.
57 #pod
58 #pod =cut
59  
60 sub in_node_family {
61 0 ▶ my ($self, $family) = @_;
Subroutine in_node_family: not called CC=4 SCAR=30.0
Pod documented
62 0 ▶ $family = $self->hub->node_family($family) unless ref $family;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $family 0 0 0
63  
64 0 for my $node_family (@{ $self->families }) {
65 0 ▶ return 1 if $family == $node_family;
Branch: 1 branch
BranchTrueFalseTotal
if $family == $node_family 0 0 0
66 }
67  
68 0 return;
69 }
70  
71 #pod =method as_data_lines
72 #pod
73 #pod This method returns a list of lines of configuration output.
74 #pod
75 #pod By default, it returns nothing.
76 #pod
77 #pod =cut
78  
79 sub as_data_lines {
80 0 ▶ confess 'do not call ->as_data_lines in non-list context' unless wantarray;
Subroutine as_data_lines: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
unless wantarray 0 0 0
81 0 return;
82 }
83  
84 1 with 'DNS::Oterica::Role::HasHub';
85  
86 1 __PACKAGE__->meta->make_immutable;
87 1 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
88 1 1;
89  
90 __END__
91  
92 =pod
93  
94 =encoding UTF-8
95  
96 =head1 NAME
97  
98 DNS::Oterica::Node - DNSO node. belongs to families.
99  
100 =head1 VERSION
101  
102 version 0.313
103  
104 =head1 OVERVIEW
105  
106 A node is any part of a network, either a domain or a node. It is a member of
107 zero or more families.
108  
109 Like other DNS::Oterica objects, they should be created through the hub.
110  
111 =head1 PERL VERSION
112  
113 This library should run on perls released even a long time ago. It should work
114 on any version of perl released in the last five years.
115  
116 Although it may work on older versions of perl, no guarantee is made that the
117 minimum required version will not be increased. The version may be increased
118 for any reason, and there is no promise that patches will be accepted to lower
119 the minimum required perl.
120  
121 =head1 ATTRIBUTES
122  
123 =head2 domain
124  
125 This is a string representing the domain's domain name, for example
126 F<example.com>.
127  
128 =head2 families
129  
130 This is an arrayref of the families in which the node has been placed.
131  
132 =head1 METHODS
133  
134 =head2 add_to_family
135  
136 $node->add_to_family($family);
137  
138 This method adds the node to the given family, which may be given either as an
139 object or as a name.
140  
141 If the node is already in the family, nothing happens.
142  
143 =head2 in_node_family
144  
145 if ($node->in_node_family($family)) { ... }
146  
147 This method returns true if the node is a member of the named (or passed)
148 family and false otherwise.
149  
150 =head2 as_data_lines
151  
152 This method returns a list of lines of configuration output.
153  
154 By default, it returns nothing.
155  
156 =head1 AUTHOR
157  
158 Ricardo SIGNES <rjbs@semiotic.systems>
159  
160 =head1 COPYRIGHT AND LICENSE
161  
162 This software is copyright (c) 2021 by Ricardo SIGNES.
163  
164 This is free software; you can redistribute it and/or modify it under
165 the same terms as the Perl 5 programming language system itself.
166  
167 =cut
« Oterica/App.pm ↑ Summary Oterica/Hub.pm »