From: Shawn M Moore Date: Sun, 28 Sep 2008 04:01:05 +0000 (+0000) Subject: weaken for Mouse::Util which will load up Scalar::Util X-Git-Tag: 0.19~209 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=626cd940635e34f4a742f69de6354ecd83333e66;p=gitmo%2FMouse.git weaken for Mouse::Util which will load up Scalar::Util --- diff --git a/lib/Mouse/Meta/Attribute.pm b/lib/Mouse/Meta/Attribute.pm index 959f712..1588641 100644 --- a/lib/Mouse/Meta/Attribute.pm +++ b/lib/Mouse/Meta/Attribute.pm @@ -4,8 +4,7 @@ use strict; use warnings; use Carp 'confess'; -use Mouse::Util 'blessed'; -use Scalar::Util 'weaken'; +use Mouse::Util qw/blessed weaken/; sub new { my $class = shift; @@ -79,7 +78,7 @@ sub generate_accessor { $accessor .= '$self->{$key} = $_;'; if ($attribute->is_weak_ref) { - $accessor .= 'Scalar::Util::weaken($self->{$key}) if ref($self->{$key});'; + $accessor .= 'weaken($self->{$key}) if ref($self->{$key});'; } if ($trigger) { diff --git a/lib/Mouse/Object.pm b/lib/Mouse/Object.pm index 623fa64..8c36df3 100644 --- a/lib/Mouse/Object.pm +++ b/lib/Mouse/Object.pm @@ -3,7 +3,7 @@ package Mouse::Object; use strict; use warnings; -use Scalar::Util qw/weaken/; +use Mouse::Util qw/weaken/; use Carp 'confess'; sub new { diff --git a/lib/Mouse/Util.pm b/lib/Mouse/Util.pm index 51aa3f9..aeaaf3f 100644 --- a/lib/Mouse/Util.pm +++ b/lib/Mouse/Util.pm @@ -145,5 +145,11 @@ for my $module_name (keys %dependencies) { } } +push @EXPORT_OK, qw(weaken); +sub weaken { + require Scalar::Util; + goto \&Scalar::Util::weaken; +} + 1;