line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package RapidApp::JSONFunc; |
2
|
6
|
|
|
6
|
|
45
|
use strict; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
195
|
|
3
|
6
|
|
|
6
|
|
34
|
use warnings; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
171
|
|
4
|
6
|
|
|
6
|
|
34
|
use Moose; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
40
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# This object allows returning functions within JSON. To prevent the function from being |
7
|
|
|
|
|
|
|
# quoted (i.e. turned into a string), this object must be encoded with RapidApp::JSON::MixedEncoder |
8
|
|
|
|
|
|
|
# which extends JSON::PP and modifies the behavior to return TO_JSON_RAW as-is |
9
|
|
|
|
|
|
|
|
10
|
6
|
|
|
6
|
|
39441
|
use RapidApp::Util qw(:all); |
|
6
|
|
|
|
|
18
|
|
|
6
|
|
|
|
|
2340
|
|
11
|
6
|
|
|
6
|
|
47
|
use RapidApp::JSON::MixedEncoder; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
1396
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has 'func' => ( is => 'ro', required => 1, isa => 'Str' ); |
14
|
|
|
|
|
|
|
has 'parm' => ( is => 'ro', required => 0 ); |
15
|
|
|
|
|
|
|
has 'raw' => ( is => 'ro', default => 0 ); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has 'json' => ( is => 'ro', lazy_build => 1 ); |
18
|
|
|
|
|
|
|
sub _build_json { |
19
|
6
|
|
|
6
|
|
12
|
my $self = shift; |
20
|
6
|
|
|
|
|
32
|
return RapidApp::JSON::MixedEncoder->new; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub TO_JSON { |
24
|
13
|
|
|
13
|
0
|
23
|
my $self = shift; |
25
|
13
|
100
|
|
|
|
394
|
return $self->func if ($self->raw); |
26
|
7
|
|
|
|
|
188
|
return $self->func . '(' . $self->json->encode($self->parm) . ')'; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub TO_JSON_RAW { |
30
|
13
|
|
|
13
|
0
|
38
|
return (shift)->TO_JSON; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
6
|
|
|
6
|
|
53
|
no Moose; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
39
|
|
35
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
36
|
|
|
|
|
|
|
1; |