File: Base.pm

package info (click to toggle)
libdata-javascript-anon-perl 1.03-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 188 kB
  • sloc: perl: 1,454; makefile: 4
file content (86 lines) | stat: -rw-r--r-- 1,080 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#line 1
package Module::Install::Base;

use strict 'vars';
use vars qw{$VERSION};
BEGIN {
	$VERSION = '0.85';
}

# Suspend handler for "redefined" warnings
BEGIN {
	my $w = $SIG{__WARN__};
	$SIG{__WARN__} = sub { $w };
}

### This is the ONLY module that shouldn't have strict on
# use strict;

#line 45

sub new {
	my ($class, %args) = @_;

	foreach my $method ( qw(call load) ) {
		next if defined &{"$class\::$method"};
		*{"$class\::$method"} = sub {
			shift()->_top->$method(@_);
		};
	}

	bless( \%args, $class );
}

#line 66

sub AUTOLOAD {
	my $self = shift;
	local $@;
	my $autoload = eval {
		$self->_top->autoload
	} or return;
	goto &$autoload;
}

#line 83

sub _top {
	$_[0]->{_top};
}

#line 98

sub admin {
	$_[0]->_top->{admin}
	or
	Module::Install::Base::FakeAdmin->new;
}

#line 114

sub is_admin {
	$_[0]->admin->VERSION;
}

sub DESTROY {}

package Module::Install::Base::FakeAdmin;

my $fake;

sub new {
	$fake ||= bless(\@_, $_[0]);
}

sub AUTOLOAD {}

sub DESTROY {}

# Restore warning handler
BEGIN {
	$SIG{__WARN__} = $SIG{__WARN__}->();
}

1;

#line 162