File Coverage

blib/lib/Kelp/Module/JSON.pm
Criterion Covered Total %
statement 10 10 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod 1 1 100.0
total 14 14 100.0


line stmt bran cond sub pod time code
1             package Kelp::Module::JSON;
2              
3 28     28   13684 use Kelp::Base 'Kelp::Module';
  28         73  
  28         160  
4              
5 28     28   2041 use JSON::MaybeXS;
  28         62  
  28         4426  
6              
7             sub build {
8 37     37 1 173 my ( $self, %args ) = @_;
9             my $json = JSON::MaybeXS->new(
10 37         268 map { $_ => $args{$_} } keys %args
  112         424  
11             );
12 37         980 $self->register( json => $json );
13             }
14              
15             1;
16              
17             __END__
18              
19             =head1 NAME
20              
21             Kelp::Module::JSON - Simple JSON module for a Kelp application
22              
23             =head1 SYNOPSIS
24              
25             package MyApp;
26             use Kelp::Base 'Kelp';
27              
28             sub some_route {
29             my $self = shift;
30             return $self->json->encode( { yes => 1 } );
31             }
32              
33             =head1 REGISTERED METHODS
34              
35             This module registers only one method into the application: C<json>.
36              
37             The module will try to use backends in this order: I<Cpanel::JSON::XS, JSON::XS, JSON::PP>.
38              
39             =cut