elsif (ref($handles) eq 'ARRAY') {
return map { $_ => $_ } @$handles;
}
+ elsif ( ref($handles) eq 'CODE' ) {
+ my $class_or_role = ( $self->{isa} || $self->{does} )
+ || $self->throw_error( "Cannot find delegate metaclass for attribute " . $self->name );
+ return $handles->( $self, Mouse::Meta::Class->initialize("$class_or_role"));
+ }
elsif (ref($handles) eq 'Regexp') {
my $class_or_role = ($self->{isa} || $self->{does})
|| $self->throw_error("Cannot delegate methods based on a Regexp without a type constraint (isa)");
);
} "can't create attr with generative handles parameter and no isa";
- our $TODO;
-{
- local $TODO = 'handles => CODE is not supported';
::lives_ok {
has child_d => (
isa => "ChildD",
}
);
} "can't create attr with generative handles parameter and no isa";
-}
::lives_ok {
has child_e => (
);
} "can delegate to non moose class using explicit method list";
-{
- local $TODO = 'handles => CODE is not supported';
my $delegate_class;
::lives_ok {
has child_f => (
} "subrefs on non moose class give no meta";
::is( $delegate_class, "ChildF", "plain classes are handed down to subs" );
-}
::lives_ok {
has child_g => (