| 1 | package Courriel::Role::Streams; | ||
| 2 | |||
| 3 | 10 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 10 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 10 | ▶ | use namespace::autoclean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 10 | our $VERSION = '0.49'; | |
| 8 | |||
| 9 | 10 | ▶ | use Courriel::Types qw( Streamable ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | 10 | ▶ | use Params::ValidationCompiler qw( validation_for ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | |||
| 12 | 10 | ▶ | use Moose::Role; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | |||
| 14 | { | ||
| 15 | 10 | my $validator = validation_for( | |
| 16 | params => [ output => { type => Streamable } ], | ||
| 17 | named_to_list => 1, | ||
| 18 | ); | ||
| 19 | |||
| 20 | 10 | ▶ | sub stream_to { |
|
Subroutine
stream_to: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 21 | 10 | my $self = shift; | |
| 22 | 10 | my ($output) = $validator->(@_); | |
| 23 | |||
| 24 | 10 | $self->_stream_to($output); | |
| 25 | |||
| 26 | 10 | return; | |
| 27 | } | ||
| 28 | } | ||
| 29 | |||
| 30 | 10 | ▶ | sub as_string { |
|
Subroutine
as_string: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 31 | 10 | my $self = shift; | |
| 32 | |||
| 33 | 10 | my $string = q{}; | |
| 34 | |||
| 35 | 10 | $self->stream_to( output => $self->_string_output( \$string ) ); | |
| 36 | |||
| 37 | 10 | return $string; | |
| 38 | } | ||
| 39 | |||
| 40 | 10 | ▶ | sub _string_output { |
|
Subroutine
_string_output: called CC=1 SCAR=0.0
| |||
| 41 | 10 | my $self = shift; | |
| 42 | 10 | my $stringref = shift; | |
| 43 | |||
| 44 | 10 | my $string = q{}; | |
| 45 | 10 | ▶ | return sub { ${$stringref} .= $_ for @_ }; |
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||
| 46 | } | ||
| 47 | |||
| 48 | 10 | 1; | |