File Coverage

lib/Net/ISC/DHCPd/Config/Host/HardwareEthernet.pm
Criterion Covered Total %
statement 9 15 60.0
branch n/a
condition n/a
subroutine 3 7 42.8
pod 4 4 100.0
total 16 26 61.5


line stmt bran cond sub pod time code
1             package Net::ISC::DHCPd::Config::Host::HardwareEthernet;
2              
3             =head1 NAME
4              
5             Net::ISC::DHCPd::Config::Host::HardwareEthernet - Misc option 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 one of the
13             lines below
14              
15             hardware ethernet $value_attribute_value;
16              
17             =head1 SYNOPSIS
18              
19             See L<Net::ISC::DHCPd::Config/SYNOPSIS>.
20              
21             =cut
22              
23 21     21   13172 use Moose;
  21         61  
  21         145  
24 21     21   114940 use Net::ISC::DHCPd::Types 'Mac';
  21         64  
  21         140  
25              
26             with 'Net::ISC::DHCPd::Config::Role';
27              
28             # not sure how I feel about the overload. I would rather coerce the values
29             # into a Mac type, but I want case preserved from input to output. I only
30             # want comparisions to be insensitive.
31              
32 21         225 use overload '==' => \&myequals,
33             'eq' => \&myequals,
34 21     21   58555 q("") => \&get_value;
  21         44  
35              
36             =head1 ATTRIBUTES
37              
38             =head2 myequals
39              
40             equality check overload for case insensitive comparision
41              
42             =cut
43              
44             sub myequals {
45 0     0 1   return (uc($_[0]->value) eq uc($_[1]));
46             }
47              
48             =head2 get_value
49              
50             for overload q("")
51              
52             =cut
53              
54 0     0 1   sub get_value { uc(shift->value) }
55              
56             =head2 value
57              
58             Value of the option - See L</DESCRIPTION> for details.
59              
60             =cut
61              
62             has value => (
63             is => 'ro',
64             isa => Mac,
65             coerce => 1,
66             );
67              
68             =head2 regex
69              
70             See L<Net::ISC::DHCPd::Config::Role/regex>.
71              
72             =cut
73              
74             our $regex = qr{^\s* hardware \s+ ethernet \s+ (.*) ;}x;
75              
76             =head1 METHODS
77              
78             =head2 captured_to_args
79              
80             See L<Net::ISC::DHCPd::Config::Role/captured_to_args>.
81              
82             =cut
83              
84             sub captured_to_args {
85 0     0 1   my $value = shift;
86              
87             return {
88 0           value => $value,
89             };
90             }
91              
92             =head2 generate
93              
94             See L<Net::ISC::DHCPd::Config::Role/generate>.
95              
96             =cut
97              
98             sub generate {
99 0     0 1   my $self = shift;
100 0           return sprintf qq(hardware ethernet %s;), $self->value;
101             }
102              
103             =head1 COPYRIGHT & LICENSE
104              
105             =head1 AUTHOR
106              
107             See L<Net::ISC::DHCPd>.
108              
109             =cut
110             __PACKAGE__->meta->make_immutable;
111             1;