Jifty/Module/Pluggable.pm

filter: Statementstmt 73.0% 19 / 26 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 6 / 7 Podpod n/a totaltotal 71.4% 25 / 35 CC 2 SCAR 8.1
CC
2
Cov
68%
_require
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.2
« Jifty/Script/Plugin.pm ↑ Summary Jifty/Model/Session.pm »
1 package Jifty::Module::Pluggable;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use base qw/Module::Pluggable/;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 =head1 NAME
7  
8 Jifty::Module::Pluggable - Jifty-specific helper for Module::Pluggable
9  
10  
11 =head1 DESCRIPTION
12  
13 A custom subclass of Module::Pluggable to override the C<require>
14 mechanism with one that better fits our own view of the world.
15  
16 =head2 require
17  
18 Date: October 24, 2006 12:19:31 AM PDT
19 From: simon@thegestalt.org
20 Subject: Re: Module::Pluggable and CORE::require
21 To: jesse@bestpractical.com
22  
23 On Mon, Oct 23, 2006 at 09:11:22PM -0700, Jesse Vincent said:
24 does this thread make any sense to you? It looks like
25 Module::Pluggable is interacting poorly with UNIVERSAL::require?
26  
27 Module::Pluggable used to to use UNIVERSAL::require but I switched
28 because I was trying to get rid of dependencies.
29  
30 I farmed the requiring stuff off to it's own _require method in order to
31 make it easy to subclass so that people could override how the require
32 was done.
33  
34  
35 =head3 But Simon is lying...
36  
37 What we actually need to override is Module::Pluggable::Object::_require, which we do below.
38  
39  
40 =cut
41  
42  
43 1 ▶use Module::Pluggable::Object;
Subroutine BEGIN: called CC=1 SCAR=0.0
44 1 ▶use UNIVERSAL::require;
Subroutine BEGIN: called CC=1 SCAR=0.0
45  
46 1 ▶no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
47 0 ▶sub Module::Pluggable::Object::_require {
Subroutine _require: not called CC=2 SCAR=17.9
48 0 my $self = shift;
49 0 my $module = shift;
50  
51 # Module::Pluggable::Object::_require expects a true value (the error message) on failure
52 # On success, it expects you to return undef.
53  
54 0 ▶ return if $module =~/\.#/;
Branch: 1 branch
BranchTrueFalseTotal
if $module =~ /\.#/ 0 0 0
55 0 eval { Jifty::Util->require($module); };
56 0 my $err = $@;
57 0 return $err;
58 }
59  
60 1 1;
« Jifty/Script/Plugin.pm ↑ Summary Jifty/Model/Session.pm »