# this is the method map you define ...
has 'provides' => (
- is => 'ro',
- isa => 'HashRef',
- required => 1,
+ is => 'ro',
+ isa => 'HashRef',
+ default => sub {{}}
);
before '_process_options' => sub {
my ($self, $name, $options) = @_;
- if (exists $options->{provides}) {
+ if (exists $options->{provides} ||
+ exists $options->{isa} && $options->{isa} =~ /^.*?\[.*?\]$/) {
$self->process_options_for_provides($options);
}
};
);
has 'container_type_constraint' => (
- is => 'rw',
- isa => 'Moose::Meta::TypeConstraint',
- required => 1,
+ is => 'rw',
+ isa => 'Moose::Meta::TypeConstraint',
);
before 'process_options_for_provides' => sub {
- my ($self, $options) = @_;
+ my ($self, $options) = @_;
if (exists $options->{isa}) {
my $type = $options->{isa};
--- /dev/null
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More no_plan => 1;
+use Test::Exception;
+
+BEGIN {
+ use_ok('MooseX::AttributeHelpers');
+}
+
+{
+ package Foo;
+ use Moose;
+
+ has 'bar' => (is => 'rw');
+
+ package Stuffed::Role;
+ use Moose::Role;
+
+ has 'options' => (
+ metaclass => 'Collection::Array',
+ is => 'ro',
+ isa => 'ArrayRef[Foo]',
+ );
+
+ package Bulkie::Role;
+ use Moose::Role;
+
+ has 'stuff' => (
+ metaclass => 'Collection::Array',
+ is => 'ro',
+ isa => 'ArrayRef',
+ provides => {
+ 'get' => 'get_stuff'
+ }
+ );
+
+ package Stuff;
+ use Moose;
+
+ ::lives_ok {
+ with 'Stuffed::Role';
+ } '... this should work correctly';
+
+ ::lives_ok {
+ with 'Bulkie::Role';
+ } '... this should work correctly';
+
+}