blib/lib/Langertha/Role/JSON.pm

filter: Statementstmt 79.1% 19 / 24 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 77.7% 7 / 9 Podpod 100% 5 / 5 totaltotal 78.5% 33 / 42 CC 3 SCAR 4.5
CC
3
Cov
75%
decode_json_text
2.5
decode_json_text
2.5
encode_json_text
1.1
CRAP 1.6
« blib/lib/Langertha/Role/StaticModels.pm ↑ Summary blib/lib/Langertha/Manifest/Auth.pm »
1 package Langertha::Role::JSON;
2 # ABSTRACT: Role for JSON
3 194 our $VERSION = '0.505';
4 194 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 194 ▶use JSON::MaybeXS;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 194 ▶use Encode qw( encode_utf8 decode_utf8 );
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 7548 ▶sub json { shift->_json }
Subroutine json: called CC=1 SCAR=0.0
Pod documented
9  
10 2 ▶sub decode_json_text {
Subroutine decode_json_text: called CC=2 SCAR=9.2
Pod documented
11 0 ▶ my ( $self, $text ) = @_;
Subroutine decode_json_text: not called CC=2 SCAR=9.2
Pod documented
12 0 ▶ return undef unless defined $text;
Branch: 2 branches
BranchTrueFalseTotal
unless defined $text 1 1 2
unless defined $text 0 0 0
13 0 return $self->_json->decode(encode_utf8($text));
14 }
15  
16  
17 252 ▶sub encode_json_text {
Subroutine encode_json_text: called CC=1 SCAR=1.2
Pod documented
18 0 ▶ my ( $self, $data ) = @_;
Subroutine encode_json_text: not called CC=1 SCAR=1.2
Pod documented
19 0 return decode_utf8( $self->_json->encode($data) );
20 }
21  
22  
23  
24 194 has _json => (
25 is => 'ro',
26 lazy_build => 1,
27 );
28 # convert_blessed => 1 lets the encoder serialize the distribution's value
29 # objects (Usage, Cost, Tool, ToolCall, ToolChoice, UsageRecord, ...) through
30 # their TO_JSON, matching what those classes' POD calls "the house default".
31 # Plain request bodies carry no blessed values, so this changes nothing for
32 # them; it only turns a croak into a serialization when a caller hands a value
33 # object to $engine->json. -- karr k120
34 2771 ▶sub _build__json { JSON::MaybeXS->new( utf8 => 1, canonical => 1, convert_blessed => 1 ) }
Subroutine _build__json: called CC=1 SCAR=0.0
35  
36  
37 194 1;
38  
39 __END__
« blib/lib/Langertha/Role/StaticModels.pm ↑ Summary blib/lib/Langertha/Manifest/Auth.pm »