release-1.10release-1.7release-1.8release-1.9
|
Last change
on this file since d27ecf3 was
d27ecf3,
checked in by Nelson Elhage <nelhage@mit.edu>, 16 years ago
|
|
Check in Module::Install for Twitter
|
-
Property mode set to
100644
|
|
File size:
1014 bytes
|
| Line | |
|---|
| 1 | #line 1 |
|---|
| 2 | package Module::Install::Base; |
|---|
| 3 | |
|---|
| 4 | use strict 'vars'; |
|---|
| 5 | use vars qw{$VERSION}; |
|---|
| 6 | BEGIN { |
|---|
| 7 | $VERSION = '0.91'; |
|---|
| 8 | } |
|---|
| 9 | |
|---|
| 10 | # Suspend handler for "redefined" warnings |
|---|
| 11 | BEGIN { |
|---|
| 12 | my $w = $SIG{__WARN__}; |
|---|
| 13 | $SIG{__WARN__} = sub { $w }; |
|---|
| 14 | } |
|---|
| 15 | |
|---|
| 16 | #line 42 |
|---|
| 17 | |
|---|
| 18 | sub new { |
|---|
| 19 | my $class = shift; |
|---|
| 20 | unless ( defined &{"${class}::call"} ) { |
|---|
| 21 | *{"${class}::call"} = sub { shift->_top->call(@_) }; |
|---|
| 22 | } |
|---|
| 23 | unless ( defined &{"${class}::load"} ) { |
|---|
| 24 | *{"${class}::load"} = sub { shift->_top->load(@_) }; |
|---|
| 25 | } |
|---|
| 26 | bless { @_ }, $class; |
|---|
| 27 | } |
|---|
| 28 | |
|---|
| 29 | #line 61 |
|---|
| 30 | |
|---|
| 31 | sub AUTOLOAD { |
|---|
| 32 | local $@; |
|---|
| 33 | my $func = eval { shift->_top->autoload } or return; |
|---|
| 34 | goto &$func; |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | #line 75 |
|---|
| 38 | |
|---|
| 39 | sub _top { |
|---|
| 40 | $_[0]->{_top}; |
|---|
| 41 | } |
|---|
| 42 | |
|---|
| 43 | #line 90 |
|---|
| 44 | |
|---|
| 45 | sub admin { |
|---|
| 46 | $_[0]->_top->{admin} |
|---|
| 47 | or |
|---|
| 48 | Module::Install::Base::FakeAdmin->new; |
|---|
| 49 | } |
|---|
| 50 | |
|---|
| 51 | #line 106 |
|---|
| 52 | |
|---|
| 53 | sub is_admin { |
|---|
| 54 | $_[0]->admin->VERSION; |
|---|
| 55 | } |
|---|
| 56 | |
|---|
| 57 | sub DESTROY {} |
|---|
| 58 | |
|---|
| 59 | package Module::Install::Base::FakeAdmin; |
|---|
| 60 | |
|---|
| 61 | my $fake; |
|---|
| 62 | |
|---|
| 63 | sub new { |
|---|
| 64 | $fake ||= bless(\@_, $_[0]); |
|---|
| 65 | } |
|---|
| 66 | |
|---|
| 67 | sub AUTOLOAD {} |
|---|
| 68 | |
|---|
| 69 | sub DESTROY {} |
|---|
| 70 | |
|---|
| 71 | # Restore warning handler |
|---|
| 72 | BEGIN { |
|---|
| 73 | $SIG{__WARN__} = $SIG{__WARN__}->(); |
|---|
| 74 | } |
|---|
| 75 | |
|---|
| 76 | 1; |
|---|
| 77 | |
|---|
| 78 | #line 154 |
|---|
Note: See
TracBrowser
for help on using the repository browser.