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   14226 use Kelp::Base 'Kelp::Module';
  28         65  
  28         173  
4              
5 28     28   2051 use JSON::MaybeXS;
  28         61  
  28         4533  
6              
7             sub build {
8 37     37 1 152 my ( $self, %args ) = @_;
9             my $json = JSON::MaybeXS->new(
10 37         125 map { $_ => $args{$_} } keys %args
  112         434  
11             );
12 37         1069 $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