File Coverage

blib/lib/Devel/Unplug/OO.pm
Criterion Covered Total %
statement 18 18 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod 1 1 100.0
total 25 25 100.0


line stmt bran cond sub pod time code
1             package Devel::Unplug::OO;
2              
3 2     2   30506 use strict;
  2         10  
  2         132  
4 2     2   10 use warnings;
  2         8  
  2         48  
5 2     2   592 use Devel::Unplug ();
  2         16  
  2         59  
6              
7             =head1 NAME
8              
9             Devel::Unplug::OO - OO interface to L
10              
11             =head1 VERSION
12              
13             This document describes Devel::Unplug::OO version 0.03
14              
15             =cut
16              
17 2     2   8 use vars qw($VERSION @ISA);
  2         14  
  2         266  
18              
19             $VERSION = '0.03';
20              
21             =head1 SYNOPSIS
22              
23             {
24             my $unp = Devel::Unplug::OO->new( 'Some::Module' );
25             eval "use Some::Module";
26             like $@, qr{Some::Module}, "failed OK";
27             }
28             eval "use Some::Module";
29             ok !$@, "loaded OK";
30              
31             =head1 DESCRIPTION
32              
33             C is an object oriented wrapper around
34             L. It provides a convenient interface for unplugging a
35             set of modules for the life of a particular scope and then automatically
36             inserting them at the end of the scope.
37              
38             =cut
39              
40             =head1 INTERFACE
41              
42             =head2 C<< new( $module ... ) >>
43              
44             Make a new C. Any modules named as parameters
45             will be unplugged. When the returned object is destroyed they will
46             be re-inserted.
47              
48             # Unplug
49             my $u = Devel::Unplug::OO->new( 'Some::Module' );
50            
51             # Insert
52             undef $u;
53              
54             =cut
55              
56             sub new {
57 1     1 1 13 my $class = shift;
58 1         5 my $self = bless [@_], $class;
59 1         12 Devel::Unplug::unplug( @$self );
60 1         4 return $self;
61             }
62              
63             sub DESTROY {
64 1     1   829 my $self = shift;
65 1         10 Devel::Unplug::insert( @$self );
66             }
67              
68             1;
69             __END__