| 1 | ### plugin implementation | ||||||||||
| 2 | { package Catalyst::Plugin::Server; | ||||||||||
| 3 | |||||||||||
| 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 | 1 | ▶ | use base qw/Class::Data::Inheritable/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use MRO::Compat; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | our $VERSION = '0.28'; | ||||||||||
| 10 | |||||||||||
| 11 | my $ReqClass = 'Catalyst::Plugin::Server::Request'; | ||||||||||
| 12 | |||||||||||
| 13 | __PACKAGE__->mk_classdata('server'); | ||||||||||
| 14 | |||||||||||
| 15 | 0 | ▶ | sub setup_dispatcher { | ||||||||
|
Subroutine
setup_dispatcher: not called CC=1 SCAR=6.9
| |||||||||||
| 16 | 0 | my $class = shift; | |||||||||
| 17 | 0 | $class->next::method(@_); | |||||||||
| 18 | |||||||||||
| 19 | ### Load Server class | ||||||||||
| 20 | 0 | $class->server(Catalyst::Plugin::Server::Backend->new($class)); | |||||||||
| 21 | |||||||||||
| 22 | ### Load our custom request_class | ||||||||||
| 23 | 0 | $class->request_class( $ReqClass ); | |||||||||
| 24 | } | ||||||||||
| 25 | |||||||||||
| 26 | 0 | ▶ | sub prepare_action { | ||||||||
|
Subroutine
prepare_action: not called CC=2 SCAR=17.9
| |||||||||||
| 27 | 0 | my $c = shift; | |||||||||
| 28 | |||||||||||
| 29 | ### since we have a custom request class now, we have to | ||||||||||
| 30 | ### be sure no one changed it from underneath us! | ||||||||||
| 31 | 0 | ▶ | unless( $c->req->isa($ReqClass) ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | 0 | $c->log->warn( "Request class no longer inherits from " . | |||||||||
| 33 | "$ReqClass -- this may break things!" ); | ||||||||||
| 34 | } | ||||||||||
| 35 | 0 | $c->next::method( @_ ); | |||||||||
| 36 | } | ||||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | ### plugin backend object | ||||||||||
| 40 | { package Catalyst::Plugin::Server::Backend; | ||||||||||
| 41 | |||||||||||
| 42 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 43 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 44 | 1 | ▶ | use base qw/Class::Accessor::Fast/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 45 | |||||||||||
| 46 | sub new { | ||||||||||
| 47 | my $class = shift; | ||||||||||
| 48 | my $c = shift; | ||||||||||
| 49 | my $self = $class->next::method( @_ ); | ||||||||||
| 50 | } | ||||||||||
| 51 | |||||||||||
| 52 | sub register_server { | ||||||||||
| 53 | my ($self, $name, $class) = @_; | ||||||||||
| 54 | return unless ($name && $class); | ||||||||||
| 55 | |||||||||||
| 56 | $self->mk_accessors($name); | ||||||||||
| 57 | $self->$name($class); | ||||||||||
| 58 | } | ||||||||||
| 59 | } | ||||||||||
| 60 | |||||||||||
| 61 | ### the request class addition ### | ||||||||||
| 62 | { package Catalyst::Plugin::Server::Request; | ||||||||||
| 63 | |||||||||||
| 64 | use strict; | ||||||||||
| 65 | use warnings; | ||||||||||
| 66 | use Data::Dumper; | ||||||||||
| 67 | |||||||||||
| 68 | use base qw/Catalyst::Request Class::Accessor::Fast/; | ||||||||||
| 69 | |||||||||||
| 70 | *params = *parameters; | ||||||||||
| 71 | |||||||||||
| 72 | sub register_server { | ||||||||||
| 73 | my ($self, $name, $class) = @_; | ||||||||||
| 74 | return unless ($name && $class); | ||||||||||
| 75 | |||||||||||
| 76 | $self->mk_accessors($name); | ||||||||||
| 77 | $self->$name($class); | ||||||||||
| 78 | } | ||||||||||
| 79 | } | ||||||||||
| 80 | |||||||||||
| 81 | 1; | ||||||||||
| 82 | |||||||||||
| 83 | __END__ | ||||||||||