6 our @EXPORT = qw(_getglob _install_modifier _maybe_load_module);
8 sub _getglob { no strict 'refs'; \*{$_[0]} }
10 sub _install_modifier {
11 require Class::Method::Modifiers;
12 my ($into, $type, $name, $code) = @_;
13 my $ref = ref(my $to_modify = $into->can($name));
15 # if it isn't CODE, then either we're about to die, or it's a blessed
16 # coderef - if it's a blessed coderef it might be deferred, and the
17 # user's already doing something clever so a minor speed hit is meh.
19 if ($ref && $ref ne 'CODE') {
20 require Sub::Defer; Sub::Defer::undefer_sub($to_modify);
22 Class::Method::Modifiers::install_modifier(@_);
27 sub _maybe_load_module {
28 return $MAYBE_LOADED{$_[0]} if exists $MAYBE_LOADED{$_[0]};
29 (my $proto = $_[0]) =~ s/::/\//g;
30 if (eval { require "${proto}.pm"; 1 }) {
31 $MAYBE_LOADED{$_[0]} = 1;
33 if (exists $INC{"${proto}.pm"}) {
34 warn "$_[0] exists but failed to load with error: $@";
36 $MAYBE_LOADED{$_[0]} = 0;
38 return $MAYBE_LOADED{$_[0]};