File Coverage

blib/lib/Dancer/Serializer/Abstract.pm
Criterion Covered Total %
statement 21 21 100.0
branch 2 2 100.0
condition n/a
subroutine 9 9 100.0
pod 0 5 0.0
total 32 37 86.4


line stmt bran cond sub pod time code
1             package Dancer::Serializer::Abstract;
2             our $AUTHORITY = 'cpan:SUKRIA';
3             # ABSTRACT: Base serialiser class for Dancer
4             $Dancer::Serializer::Abstract::VERSION = '1.3520';
5 165     165   1452 use strict;
  165         401  
  165         4695  
6 165     165   878 use warnings;
  165         467  
  165         3748  
7 165     165   899 use Carp;
  165         394  
  165         9041  
8 165     165   1154 use base 'Dancer::Engine';
  165         423  
  165         45873  
9              
10 1     1 0 968 sub serialize { confess 'must be implemented' }
11 1     1 0 864 sub deserialize { confess 'must be implemented' }
12              
13             # must be implemented to declare if the serializer can be used or not
14             # most of the time, just use :
15             # Dancer::ModuleLoader->load('Your::Serializer::Deps');
16 1     1 0 697 sub loaded {0}
17              
18             # should be implemented, fallback to text/plain if not
19 4     4 0 48 sub content_type {'text/plain'}
20              
21             # most serializer don't have to overload this one
22             sub support_content_type {
23 30     30 0 90 my ($self, $ct) = @_;
24 30 100       120 return unless $ct;
25 11         51 my @toks = split ';', $ct;
26 11         34 $ct = lc($toks[0]);
27 11         44 return $ct eq $self->content_type;
28             }
29              
30             1;
31              
32             __END__