| 1 | package App::RecordStream::OutputStream; | ||||||||||
| 2 | |||||||||||
| 3 | =head1 NAME | ||||||||||
| 4 | |||||||||||
| 5 | App::RecordStream::OutputStream | ||||||||||
| 6 | |||||||||||
| 7 | =head1 AUTHOR | ||||||||||
| 8 | |||||||||||
| 9 | Benjamin Bernard <perlhacker@benjaminbernard.com> | ||||||||||
| 10 | Keith Amling <keith.amling@gmail.com> | ||||||||||
| 11 | |||||||||||
| 12 | =head1 DESCRIPTION | ||||||||||
| 13 | |||||||||||
| 14 | The class responsible for knowing the conversion from in-memory | ||||||||||
| 15 | records to record stream wire format (currently JSON). | ||||||||||
| 16 | |||||||||||
| 17 | =head1 SYNOPSIS | ||||||||||
| 18 | |||||||||||
| 19 | use App::RecordStream::OutputStream; | ||||||||||
| 20 | |||||||||||
| 21 | my $string = App::RecordStream::OutputStream::hashref_string($record); | ||||||||||
| 22 | |||||||||||
| 23 | |||||||||||
| 24 | =head1 PUBLIC METHODS | ||||||||||
| 25 | |||||||||||
| 26 | =over 4 | ||||||||||
| 27 | |||||||||||
| 28 | =item my $string = App::RecordStream::OutputStream::hashref_string($record); | ||||||||||
| 29 | |||||||||||
| 30 | Takes a record and produces the string format for passage between | ||||||||||
| 31 | recs processes. | ||||||||||
| 32 | |||||||||||
| 33 | =back | ||||||||||
| 34 | |||||||||||
| 35 | =cut | ||||||||||
| 36 | |||||||||||
| 37 | 112 | our $VERSION = "4.0.23"; | |||||||||
| 38 | |||||||||||
| 39 | 112 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 40 | 112 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 41 | |||||||||||
| 42 | 112 | ▶ | use JSON::MaybeXS; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 43 | |||||||||||
| 44 | 112 | my $json = JSON->new(); | |||||||||
| 45 | 112 | $json->allow_nonref(1); | |||||||||
| 46 | 112 | $json->allow_blessed(1); | |||||||||
| 47 | 112 | $json->convert_blessed(1); | |||||||||
| 48 | 112 | ▶ | $json->canonical(1) if $ENV{HARNESS_ACTIVE}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | |||||||||||
| 50 | sub hashref_string { | ||||||||||
| 51 | 37 | ▶ | my $record = shift; | ||||||||
|
Subroutine
hashref_string: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 52 | 37 | return $json->encode($record); | |||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | 112 | 1; | |||||||||