blib/lib/Zabbix2/API/Template.pm untested

filter: Statementstmt 0.0% 0 / 34 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 2 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 55 SCAR 24.8
CC
3
Cov
0%
id
6.0
_prefix
6.0
_extension
2.0
CRAP 12.0
1 package Zabbix2::API::Template;
2  
3 use strict;
4 use warnings;
5 use 5.010;
6 use Carp;
7  
8 use Moo::Lax;
9 extends qw/Zabbix2::API::CRUDE/;
10  
11 has 'items' => (is => 'ro',
12 lazy => 1,
13 builder => '_fetch_items');
14  
15 sub id {
16 ## mutator for id
17 my ($self, $value) = @_;
18 if (defined $value) {
19 $self->data->{templateid} = $value;
20 return $self->data->{templateid};
21 } else {
22 return $self->data->{templateid};
23 }
24 }
25  
26 sub _prefix {
27 my (undef, $suffix) = @_;
28 if ($suffix) {
29 return 'template'.$suffix;
30 } else {
31 return 'template';
32 }
33 }
34  
35 sub _extension {
36 return (output => 'extend');
37 }
38  
39 sub name {
40 my $self = shift;
41 return $self->data->{host} || '';
42 }
43  
44 sub _fetch_items {
45 my $self = shift;
46 my $items = $self->{root}->fetch('Item', params => { templateids => [ $self->data->{templateid} ] });
47 return $items;
48 }
49  
50 1;
51 __END__