blib/lib/Raisin/Plugin.pm

filter: Statementstmt 86.4% 32 / 37 Branchbran 60.0% 6 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 88.8% 8 / 9 Podpod 50.0% 2 / 4 totaltotal 80.0% 48 / 60 CC 6 SCAR 12.9
CC
6
Cov
81%
register
7.0
__ANON__
2.0
BEGIN
1.0
CRAP 3.6
« blib/lib/Raisin/Middleware/Formatter.pm ↑ Summary blib/lib/Raisin/Entity/Object.pm »
1 #!perl
2 #PODNAME: Raisin::Plugin
3 #ABSTRACT: Base class for Raisin plugins
4  
5 14 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 14 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 package Raisin::Plugin;
9 14 $Raisin::Plugin::VERSION = '0.94';
10 14 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 11 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
13 11 my ($class, $app) = @_;
14 11 my $self = bless {}, $class;
15 11 $self->{app} = $app;
16 11 $self;
17 }
18  
19 57 ▶sub app { shift->{app} }
Subroutine app: called CC=1 SCAR=0.0
Pod undocumented
20  
21 1 ▶sub build {
Subroutine build: called CC=1 SCAR=0.0
Pod documented
22 1 my ($self, %args) = @_;
23 }
24  
25 10 ▶sub register {
Subroutine register: called CC=6 SCAR=19.4
Pod documented
26 10 my ($self, %items) = @_;
27  
28 10 ▶ while (my ($name, $item) = each %items) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %items) 16 10 26
29 14 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
30 #no warnings 'redefine';
31  
32 16 my $class = ref $self->app;
33 16 my $caller = $self->app->{caller};
34  
35 16 my $glob = "${class}::${name}";
36 16 ▶ my $app_glob = $caller ? "${caller}::${name}" : undef;
Branch: 1 branch
BranchTrueFalseTotal
$caller ? : 16 0 16
37  
38 16 ▶ if ($self->app->can($name)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->app->can($name)) 0 16 16
39 0 croak "Redefining of $glob not allowed";
40 }
41  
42 16 ▶ if (ref $item eq 'CODE') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $item eq 'CODE') { } 16 0 16
43 16 *{$glob} = $item;
44 16 ▶ *{$app_glob} = $item if $app_glob;
Branch: 1 branch
BranchTrueFalseTotal
if $app_glob 16 0 16
45 }
46 else {
47 0 $self->app->{$name} = $item;
48 0 ▶ *{$glob} = sub { shift->{$name} };
Subroutine __ANON__: not called CC=1 SCAR=6.9
49 }
50 }
51 }
52  
53 14 1;
54  
55 __END__
« blib/lib/Raisin/Middleware/Formatter.pm ↑ Summary blib/lib/Raisin/Entity/Object.pm »