Commit | Line | Data |
6c74d087 |
1 | package Class::Tiny::_Utils; |
2 | |
3 | use strictures 1; |
4 | use base qw(Exporter); |
5 | |
6 | our @EXPORT = qw(_getglob _install_modifier); |
7 | |
8 | sub _getglob { no strict 'refs'; \*{$_[0]} } |
9 | |
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)); |
a165a07f |
14 | |
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. |
18 | |
19 | if ($ref && $ref ne 'CODE') { |
20 | require Sub::Defer; Sub::Defer::undefer_sub($to_modify); |
6c74d087 |
21 | } |
22 | Class::Method::Modifiers::install_modifier(@_); |
23 | } |
24 | |
25 | 1; |