3 sub _getglob { \*{$_[0]} }
4 sub _getstash { \%{"$_[0]::"} }
7 *lt_5_8_3 = $] < 5.008003
14 use base qw(Exporter);
18 _getglob _install_modifier _load_module _maybe_load_module
22 sub _install_modifier {
23 my ($into, $type, $name, $code) = @_;
25 if (my $to_modify = $into->can($name)) { # CMM will throw for us if not
27 Sub::Defer::undefer_sub($to_modify);
30 Class::Method::Modifiers::install_modifier(@_);
35 # _load_module is inlined in Role::Tiny - make sure to copy if you update it.
38 (my $proto = $_[0]) =~ s/::/\//g;
39 return 1 if $INC{"${proto}.pm"};
40 # can't just ->can('can') because a sub-package Foo::Bar::Baz
41 # creates a 'Baz::' key in Foo::Bar's symbol table
42 return 1 if grep !/::$/, keys %{_getstash($_[0])||{}};
43 require "${proto}.pm";
47 sub _maybe_load_module {
48 return $MAYBE_LOADED{$_[0]} if exists $MAYBE_LOADED{$_[0]};
49 (my $proto = $_[0]) =~ s/::/\//g;
50 if (eval { require "${proto}.pm"; 1 }) {
51 $MAYBE_LOADED{$_[0]} = 1;
53 if (exists $INC{"${proto}.pm"}) {
54 warn "$_[0] exists but failed to load with error: $@";
56 $MAYBE_LOADED{$_[0]} = 0;
58 return $MAYBE_LOADED{$_[0]};
62 return mro::get_linear_isa($_[0]);
65 our $_in_global_destruction = 0;
66 END { $_in_global_destruction = 1 }