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