File Coverage

blib/lib/RapidApp/JSON/ScriptWithData.pm
Criterion Covered Total %
statement 12 17 70.5
branch 0 2 0.0
condition n/a
subroutine 4 6 66.6
pod 0 2 0.0
total 16 27 59.2


line stmt bran cond sub pod time code
1             package RapidApp::JSON::ScriptWithData;
2              
3 6     6   37 use strict;
  6         10  
  6         162  
4 6     6   27 use warnings;
  6         11  
  6         144  
5 6     6   53 use Scalar::Util;
  6         13  
  6         237  
6 6     6   30 use RapidApp::JSON::MixedEncoder 'encode_json';
  6         12  
  6         759  
7              
8             =head1 NAME
9              
10             RapidApp::JSON::ScriptWithData
11              
12             =head1 SYNOPSIS
13              
14             use RapidApp::JSON::ScriptWithData;
15             use RapidApp::JSON::MixedEncoder 'encode_json';
16            
17             $swd= RapidApp::JSON::ScriptWithData->new(
18             'function () {',
19             'blah(12345);',
20             'var b= foo(bar(', $self->getSomething, '));',
21             'var a=', { x=>1, y=>2, z=>3 }, ';',
22             'return baz(a, b);',
23             '}'
24             );
25            
26             return encode_json($swd);
27              
28             =cut
29              
30             sub new {
31 0     0 0   my ($class, @args)= @_;
32 0           return bless \@args, $class;
33             }
34              
35             sub TO_JSON_RAW {
36 0     0 0   my $self= shift;
37 0 0         return join '', (map { ref $_? encode_json($_) : $_ } @$self);
  0            
38             }
39              
40             1;