File Coverage

blib/lib/Net/Versa/Director/Serializer.pm
Criterion Covered Total %
statement 8 14 57.1
branch 0 2 0.0
condition n/a
subroutine 3 4 75.0
pod n/a
total 11 20 55.0


line stmt bran cond sub pod time code
1             package Net::Versa::Director::Serializer;
2             $Net::Versa::Director::Serializer::VERSION = '0.004000';
3             # ABSTRACT: Versa Director REST API serializer
4              
5 3     3   252238 use v5.36;
  3         12  
6 3     3   444 use Moo;
  3         7644  
  3         34  
7 3     3   2899 use Types::Standard qw(Enum);
  3         113120  
  3         26  
8              
9             extends 'Role::REST::Client::Serializer';
10              
11             has '+type' => (
12             isa => Enum[qw{application/json application/vnd.yang.data+json}],
13             default => sub { 'application/json' },
14             );
15              
16             our %modules = (
17             'application/json' => {
18             module => 'JSON',
19             },
20             'application/vnd.yang.data+json' => {
21             module => 'JSON',
22             },
23             );
24              
25             has '+serializer' => (
26             default => \&_set_serializer,
27             );
28              
29 0     0     sub _set_serializer ($self) {
  0            
  0            
30 0 0         return unless $modules{$self->type};
31              
32 0           my $module = $modules{$self->type}{module};
33              
34 0           return Data::Serializer::Raw->new(
35             serializer => $module,
36             );
37             }
38              
39             1;
40              
41             __END__
42              
43             =pod
44              
45             =encoding UTF-8
46              
47             =head1 NAME
48              
49             Net::Versa::Director::Serializer - Versa Director REST API serializer
50              
51             =head1 VERSION
52              
53             version 0.004000
54              
55             =head1 AUTHOR
56              
57             Alexander Hartmaier <abraxxa@cpan.org>
58              
59             =head1 COPYRIGHT AND LICENSE
60              
61             This software is copyright (c) 2025 by Alexander Hartmaier.
62              
63             This is free software; you can redistribute it and/or modify it under
64             the same terms as the Perl 5 programming language system itself.
65              
66             =cut