unless $isa || $does;
for (grep { blessed($_) } $isa, $does) {
- confess "You must use classes/roles, not type constraints to use delegation"
+ confess "You must use classes/roles, not type constraints to use delegation ($_)"
unless $_->isa( "Moose::Meta::Class" );
}
$_ = $_->meta if defined and !ref and $_->can("meta");
}
+ $isa = Class::MOP::Class->initialize($isa) if $isa and !ref($isa);
+
return $isa || $does;
}
not only check it's local roles, but ask them as well in order to
cascade down the role hierarchy.
+=item B<add_attribute $attr_name, %params>
+
+This method does the same thing as L<Class::MOP::Class/add_attribute>, but adds
+suport for delegation.
+
+=back
+
+=head1 INTERNAL METHODS
+
+=over 4
+
+=item compute_delegation
+
+=item generate_delegation_list
+
+=item generate_delgate_method
+
+=item get_delegatable_methods
+
=back
=head1 BUGS
use strict;
use warnings;
-use Test::More tests => 36;
+use Test::More tests => 35;
use Test::Exception;
{
);
} "can delegate to non moose class using explicit method list";
- ::dies_ok {
- has child_f => (
- isa => "ChildF",
- is => "ro",
- default => sub { ChildF->new },
- handles => qr/.*/,
- );
- } "can't use regexes on foreign classes";
-
my $delegate_class;
::lives_ok {
has child_f => (
is => "ro",
default => sub { ChildF->new },
handles => sub {
- $delegate_class = $_[1];
+ $delegate_class = $_[1]->name;
},
);
} "subrefs on non moose class give no meta";