blib/lib/Magpie/Transformer/Middleware.pm

filter: Statementstmt 97.3% 36 / 37 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 88.8% 8 / 9 Podpod 0.0% 0 / 2 totaltotal 91.6% 44 / 48 CC 1 SCAR 1.1
CC
1
Cov
97%
__ANON__
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« blib/lib/Magpie/Resource/Abstract.pm ↑ Summary blib/lib/Magpie/Error/Simplified.pm »
1 package Magpie::Transformer::Middleware;
2 # ABSTRACT: Use Plack Middleware Handlers As Pipeline Components
3 1 $Magpie::Transformer::Middleware::VERSION = '1.141660';
4 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 extends 'Magpie::Transformer';
6 1 ▶use Magpie::Constants;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Plack::Response;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Plack::Request;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11  
12 1 __PACKAGE__->register_events( (qw(call_middleware)));
13  
14 2 ▶sub load_queue { return (qw( call_middleware )) }
Subroutine load_queue: called CC=1 SCAR=0.0
Pod undocumented
15  
16 1 has middleware_class => (
17 is => 'rw',
18 isa => 'Str',
19 required => 1,
20 );
21  
22 has middleware_args => (
23 is => 'rw',
24 isa => 'HashRef',
25 required => 1,
26 0 ▶ default => sub {{}},
Subroutine __ANON__: not called CC=1 SCAR=6.9
27 1 );
28  
29 sub call_middleware {
30 2 ▶ my ($self, $ctxt) = @_;
Subroutine call_middleware: called CC=1 SCAR=0.0
Pod undocumented
31 2 my $env = $self->request->env;
32 2 my $current_resp = $self->response->finalize;
33 2 my $mw_class = Plack::Util::load_class($self->middleware_class, 'Plack::Middleware');
34 2 ▶ my $app = sub { $current_resp };
Subroutine __ANON__: called CC=1 SCAR=0.0
35 2 my $mw_args = $self->middleware_args;
36 2 my $mw = $mw_class->new( app => $app, %{$mw_args});
37 2 my $r = $mw->call($env);
38 2 my $new_resp = Plack::Response->new(@$r);
39 2 $self->plack_response( $new_resp );
40 2 $self->plack_request( Plack::Request->new($env) );
41 2 return OK;
42 }
43  
44 # SEEALSO: Magpie
45  
46 1 1;
47 __END__
48 =pod
49  
50 =head1 NAME
51  
52 Magpie::Transformer::Middleware - Use Plack Middleware Handlers As Pipeline Components
53  
54 =head1 VERSION
55  
56 version 1.141660
57  
58 =head1 AUTHORS
59  
60 =over 4
61  
62 =item *
63  
64 Kip Hampton <kip.hampton@tamarou.com>
65  
66 =item *
67  
68 Chris Prather <chris.prather@tamarou.com>
69  
70 =back
71  
72 =head1 COPYRIGHT AND LICENSE
73  
74 This software is copyright (c) 2011 by Tamarou, LLC.
75  
76 This is free software; you can redistribute it and/or modify it under
77 the same terms as the Perl 5 programming language system itself.
78  
79 =cut
80  
« blib/lib/Magpie/Resource/Abstract.pm ↑ Summary blib/lib/Magpie/Error/Simplified.pm »