~ubuntu-branches/ubuntu/natty/libsignatures-perl/natty

« back to all changes in this revision

Viewing changes to inc/Module/Install/Base.pm

  • Committer: Bazaar Package Importer
  • Author(s): Ryan Niebur
  • Date: 2009-05-18 20:34:44 UTC
  • Revision ID: james.westby@ubuntu.com-20090518203444-ee3iqibpk6uxo7u8
Tags: upstream-0.05
ImportĀ upstreamĀ versionĀ 0.05

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#line 1
 
2
package Module::Install::Base;
 
3
 
 
4
$VERSION = '0.84';
 
5
 
 
6
# Suspend handler for "redefined" warnings
 
7
BEGIN {
 
8
        my $w = $SIG{__WARN__};
 
9
        $SIG{__WARN__} = sub { $w };
 
10
}
 
11
 
 
12
### This is the ONLY module that shouldn't have strict on
 
13
# use strict;
 
14
 
 
15
#line 41
 
16
 
 
17
sub new {
 
18
        my ($class, %args) = @_;
 
19
 
 
20
        foreach my $method ( qw(call load) ) {
 
21
                next if defined &{"$class\::$method"};
 
22
                *{"$class\::$method"} = sub {
 
23
                        shift()->_top->$method(@_);
 
24
                };
 
25
        }
 
26
 
 
27
        bless( \%args, $class );
 
28
}
 
29
 
 
30
#line 62
 
31
 
 
32
sub AUTOLOAD {
 
33
        my $self = shift;
 
34
        local $@;
 
35
        my $autoload = eval {
 
36
                $self->_top->autoload
 
37
        } or return;
 
38
        goto &$autoload;
 
39
}
 
40
 
 
41
#line 79
 
42
 
 
43
sub _top {
 
44
        $_[0]->{_top};
 
45
}
 
46
 
 
47
#line 94
 
48
 
 
49
sub admin {
 
50
        $_[0]->_top->{admin}
 
51
        or
 
52
        Module::Install::Base::FakeAdmin->new;
 
53
}
 
54
 
 
55
#line 110
 
56
 
 
57
sub is_admin {
 
58
        $_[0]->admin->VERSION;
 
59
}
 
60
 
 
61
sub DESTROY {}
 
62
 
 
63
package Module::Install::Base::FakeAdmin;
 
64
 
 
65
my $fake;
 
66
sub new {
 
67
        $fake ||= bless(\@_, $_[0]);
 
68
}
 
69
 
 
70
sub AUTOLOAD {}
 
71
 
 
72
sub DESTROY {}
 
73
 
 
74
# Restore warning handler
 
75
BEGIN {
 
76
        $SIG{__WARN__} = $SIG{__WARN__}->();
 
77
}
 
78
 
 
79
1;
 
80
 
 
81
#line 157