| 1 | package Uniform::HTMX::Mojolicious; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use parent 'Uniform::HTMX'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 3 | our $VERSION = '1.02'; | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 3 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 12 | 3 | my ($class, $c) = @_; | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 3 | ▶ | croak "Constructor requires a Mojolicious controller object" | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
builtin::blessed($c) and $c->isa("Mojolicious::Controller")
MC/DC50%1/2
builtin::blessed($c) and $c->isa("Mojolicious::Controller")
builtin::blessed($c)
$c->isa("Mojolicious::Controller")
Truth table66%2/3
A and B
A= builtin::blessed($c)B= $c->isa("Mojolicious::Controller")
| |||||||||||||||||||||||||||||
| 15 | unless blessed($c) && $c->isa('Mojolicious::Controller'); | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | # Extract HTTP headers from Mojo::Headers object into CGI-style key hash | ||||||||||||||||||||||||||||
| 18 | 2 | my $headers = $c->req->headers; | |||||||||||||||||||||||||||
| 19 | 2 | my %env; | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 2 | for my $name (@{ $headers->names }) { | |||||||||||||||||||||||||||
| 22 | 4 | my $key = uc($name); | |||||||||||||||||||||||||||
| 23 | 4 | $key =~ s/-/_/g; | |||||||||||||||||||||||||||
| 24 | 4 | $env{"HTTP_$key"} = $headers->header($name); | |||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 2 | return $class->SUPER::new(in => \%env, env => \%env); | |||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 1 | ▶ | sub apply { | ||||||||||||||||||||||||||
|
Subroutine
apply: called CC=5 SCAR=17.0
Pod
documented
| |||||||||||||||||||||||||||||
| 31 | 1 | my ($self, $c) = @_; | |||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 1 | ▶ | croak "apply() requires a Mojolicious controller object" | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($c) and $c->isa("Mojolicious::Controller")
MC/DC0%0/2
builtin::blessed($c) and $c->isa("Mojolicious::Controller")
builtin::blessed($c)
$c->isa("Mojolicious::Controller")
Truth table33%1/3
A and B
A= builtin::blessed($c)B= $c->isa("Mojolicious::Controller")
| |||||||||||||||||||||||||||||
| 34 | unless blessed($c) && $c->isa('Mojolicious::Controller'); | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 1 | my $out = $self->_out; | |||||||||||||||||||||||||||
| 37 | 1 | ▶ | return $c unless %$out; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 1 | my $res_headers = $c->res->headers; | |||||||||||||||||||||||||||
| 40 | 1 | for my $key (keys %$out) { | |||||||||||||||||||||||||||
| 41 | 2 | $res_headers->header($key => $out->{$key}); | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 1 | return $c; | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 3 | 1; | |||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | __END__ | ||||||||||||||||||||||||||||