| 1 | package App::AutoCRUD::View::Yaml; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use 5.010; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | extends 'App::AutoCRUD::View'; | |||||||||
| 9 | |||||||||||
| 10 | 1 | ▶ | use YAML::Any; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 1 | ▶ | use namespace::clean -except => 'meta'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 1 | ▶ | has 'yaml_flags' => ( is => 'bare', isa => 'HashRef', default => sub {{}} ); | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 15 | |||||||||||
| 16 | |||||||||||
| 17 | 1 | ▶ | sub render { | ||||||||
|
Subroutine
render: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||
| 18 | 1 | my ($self, $data, $context) = @_; | |||||||||
| 19 | |||||||||||
| 20 | # YAML modules don't have an OO API, so we must play with global variables | ||||||||||
| 21 | 1 | my $yaml_class = YAML::Any->implementation; | |||||||||
| 22 | 1 | my $local_flags = ""; | |||||||||
| 23 | 1 | ▶ | while (my ($flag, $val) = each %{$self->{yaml_flags}}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | 0 | $local_flags .= "local \$${yaml_class}::$flag = q{$val};"; | |||||||||
| 25 | } | ||||||||||
| 26 | 1 | ▶ | eval $local_flags if $local_flags; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | |||||||||||
| 28 | 1 | my $output = Dump $data; | |||||||||
| 29 | 1 | return [200, ['Content-type' => 'application/yaml'], [$output] ]; | |||||||||
| 30 | } | ||||||||||
| 31 | |||||||||||
| 32 | 1 | 1; | |||||||||
| 33 | |||||||||||
| 34 | |||||||||||
| 35 | __END__ | ||||||||||