From: Matt S Trout Date: Wed, 10 Nov 2010 05:05:49 +0000 (+0000) Subject: remove bless because it confuses things X-Git-Tag: 0.009001~42 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9187b8624f5faa77cf54e6c8e1656a4e2e23f564;p=gitmo%2FRole-Tiny.git remove bless because it confuses things --- diff --git a/lib/Moo/_Utils.pm b/lib/Moo/_Utils.pm index 0e5d787..c8549e8 100644 --- a/lib/Moo/_Utils.pm +++ b/lib/Moo/_Utils.pm @@ -8,17 +8,13 @@ our @EXPORT = qw(_getglob _install_modifier _maybe_load_module); sub _getglob { no strict 'refs'; \*{$_[0]} } sub _install_modifier { - require Class::Method::Modifiers; my ($into, $type, $name, $code) = @_; my $ref = ref(my $to_modify = $into->can($name)); - # if it isn't CODE, then either we're about to die, or it's a blessed - # coderef - if it's a blessed coderef it might be deferred, and the - # user's already doing something clever so a minor speed hit is meh. + require Sub::Defer; + Sub::Defer::undefer_sub($to_modify); - if ($ref && $ref ne 'CODE') { - require Sub::Defer; Sub::Defer::undefer_sub($to_modify); - } + require Class::Method::Modifiers; Class::Method::Modifiers::install_modifier(@_); } diff --git a/lib/Sub/Defer.pm b/lib/Sub/Defer.pm index 50688c5..816190e 100644 --- a/lib/Sub/Defer.pm +++ b/lib/Sub/Defer.pm @@ -25,9 +25,9 @@ sub defer_sub { my ($target, $maker) = @_; my $undeferred; my $deferred_string; - my $deferred = bless(sub { + my $deferred = sub { goto &{$undeferred ||= undefer_sub($deferred_string)}; - }, 'Sub::Defer::Deferred'); + }; $deferred_string = "$deferred"; $DEFERRED{$deferred} = [ $target, $maker, \$undeferred ]; *{_getglob $target} = $deferred if defined($target);