lib/Net/ISC/DHCPd/Config/Host.pm

filter: Statementstmt 88.8% 24 / 27 Branchbran 66.6% 4 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 88.8% 8 / 9 Podpod 100% 5 / 5 totaltotal 87.2% 41 / 47 SCAR 14.0
CC
4
Cov
85%
__ANON__
2.3
__ANON__
2.3
__ANON__
2.0
CRAP 4.1
« lib/Net/ISC/DHCPd/OMAPI/Control.pm ↑ Summary lib/Net/ISC/DHCPd/Config/OptionCode.pm »
1 package Net::ISC::DHCPd::Config::Host;
2  
3 =head1 NAME
4  
5 Net::ISC::DHCPd::Config::Host - Host config parameter
6  
7 =head1 DESCRIPTION
8  
9 See L<Net::ISC::DHCPd::Config::Role> for methods and attributes without
10 documentation.
11  
12 An instance from this class, comes from / will produce:
13  
14 host $name_attribute_value {
15 $keyvalues_attribute_value
16 $filenames_attribute_value
17 $options_attribute_value
18 }
19  
20 =head1 SYNOPSIS
21  
22 See L<Net::ISC::DHCPd::Config/SYNOPSIS>.
23  
24 =cut
25  
26 26 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 26 with 'Net::ISC::DHCPd::Config::Role';
29  
30 =head2 children
31  
32 See L<Net::ISC::DHCPd::Config::Role/children>.
33  
34 =cut
35  
36 sub children {
37 77 ▶ return qw/
Subroutine children: called CC=1 SCAR=0.0
Pod documented
38 Net::ISC::DHCPd::Config::Host::FixedAddress
39 Net::ISC::DHCPd::Config::Host::HardwareEthernet
40 Net::ISC::DHCPd::Config::Option
41 Net::ISC::DHCPd::Config::Filename
42 Net::ISC::DHCPd::Config::KeyValue
43 /;
44 }
45 26 __PACKAGE__->create_children(__PACKAGE__->children());
46  
47 =head1 ATTRIBUTES
48  
49 =head2 fixedaddress
50  
51 Convienence method that wraps shift->fixedaddresses->[0]
52  
53 =head2 options
54  
55 A list of parsed L<Net::ISC::DHCPd::Config::Option> objects.
56  
57 =head2 filenames
58  
59 A list of parsed L<Net::ISC::DHCPd::Config::Filename> objects. There can
60 be only one element in this list.
61  
62 =cut
63  
64 before add_filename => sub {
65 5 ▶ if(0 < int @{ $_[0]->filenames }) {
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if (0 < int @{$_[0]->filenames;}) 1 4 5
66 1 confess 'Host cannot have more than one filename';
67 }
68 26 };
69  
70 before add_fixedaddress => sub {
71 12 ▶ if(0 < int @{ $_[0]->fixedaddresses }) {
Subroutine __ANON__: called CC=2 SCAR=8.1
Branch: 1 branch
BranchTrueFalseTotal
if (0 < int @{$_[0]->fixedaddresses;}) 0 12 12
72 0 confess 'Host cannot have more than one ip address';
73 }
74 26 };
75  
76 before add_hardwareethernet => sub {
77 10 ▶ if(0 < int @{ $_[0]->hardwareethernets }) {
Subroutine __ANON__: called CC=2 SCAR=8.1
Branch: 1 branch
BranchTrueFalseTotal
if (0 < int @{$_[0]->hardwareethernets;}) 0 10 10
78 0 confess 'Host cannot have more than one mac address';
79 }
80 26 };
81  
82 sub fixedaddress {
83 0 ▶ shift->fixedaddresses->[0];
Subroutine fixedaddress: not called CC=1 SCAR=6.9
Pod documented
84 }
85  
86 =head2 hardwareethernet
87  
88 Convienence method that wraps shift->hardwareethernets->[0]
89  
90 =cut
91 sub hardwareethernet {
92 1 ▶ shift->hardwareethernets->[0];
Subroutine hardwareethernet: called CC=1 SCAR=0.0
Pod documented
93 }
94  
95 =head2 keyvalues
96  
97 A list of parsed L<Net::ISC::DHCPd::Config::KeyValue> objects.
98  
99 =head2 name
100  
101 This attribute holds a string describing the host.
102  
103 =cut
104  
105 26 has name => (
106 is => 'ro',
107 isa => 'Str',
108 );
109  
110 =head2 regex
111  
112 See L<Net::ISC::DHCPd::Config::Role/regex>.
113  
114 =cut
115  
116 26 our $regex = qr{^ \s* host \s+ (\S+)}x;
117  
118 =head1 METHODS
119  
120 =head2 captured_to_args
121  
122 See L<Net::ISC::DHCPd::Config::Role/captured_to_args>.
123  
124 =cut
125  
126 sub captured_to_args {
127 16 ▶ return { name => $_[0] };
Subroutine captured_to_args: called CC=1 SCAR=0.0
Pod documented
128 }
129  
130 =head2 generate
131  
132 See L<Net::ISC::DHCPd::Config::Role/generate>.
133  
134 =cut
135  
136 sub generate {
137 4 ▶ my $self = shift;
Subroutine generate: called CC=1 SCAR=0.0
Pod documented
138  
139 return(
140 4 'host ' .$self->name .' {',
141 $self->_generate_config_from_children,
142 '}',
143 );
144 }
145  
146 =head1 COPYRIGHT & LICENSE
147  
148 =head1 AUTHOR
149  
150 See L<Net::ISC::DHCPd>.
151  
152 =cut
153 26 __PACKAGE__->meta->make_immutable;
154 26 1;
« lib/Net/ISC/DHCPd/OMAPI/Control.pm ↑ Summary lib/Net/ISC/DHCPd/Config/OptionCode.pm »