From: gfx Date: Fri, 18 Dec 2009 04:42:25 +0000 (+0900) Subject: Lazy load for Delegation class X-Git-Tag: 0.45~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=feaa7084294785dfcc9569aac98393da09f0f640;p=gitmo%2FMouse.git Lazy load for Delegation class --- diff --git a/lib/Mouse/Meta/Attribute.pm b/lib/Mouse/Meta/Attribute.pm index 0a12d95..0f0d088 100644 --- a/lib/Mouse/Meta/Attribute.pm +++ b/lib/Mouse/Meta/Attribute.pm @@ -5,9 +5,6 @@ use Carp (); use Mouse::Meta::TypeConstraint; -#use Mouse::Meta::Method::Accessor; -use Mouse::Meta::Method::Delegation; - sub _process_options{ my($class, $name, $args) = @_; @@ -415,6 +412,8 @@ sub install_accessors{ my %handles = $attribute->_canonicalize_handles($attribute->{handles}); my $reader = $attribute->get_read_method_ref; + Mouse::Util::load_class($delegation_class); + while(my($handle_name, $method_to_call) = each %handles){ my $code = $delegation_class->_generate_delegation($attribute, $metaclass, $reader, $handle_name, $method_to_call); diff --git a/t/001_mouse/063-meta-of-metaclasses.t b/t/001_mouse/063-meta-of-metaclasses.t index 8ef6294..6582195 100644 --- a/t/001_mouse/063-meta-of-metaclasses.t +++ b/t/001_mouse/063-meta-of-metaclasses.t @@ -5,10 +5,19 @@ use warnings; use Test::More tests => 10; { + package OtherClass; + sub method {} + package Class; use Mouse; - has foo => (is => 'rw'); + # this attribute definition is intended to load submodules + + has foo => ( + is => 'rw', + isa => 'OtherClass', + handles => qr/./, + ); __PACKAGE__->meta->make_immutable; # ensure metaclasses loaded