from ArrayRef, via { Path::Class::Dir->new(@$_) };
coerce ArrayRef[$type],
- from ArrayRef[Str], via { [ map { Path::Class::Dir->new($_) } @$_ ] },
- from ArrayRef[ArrayRef], via { [ map { Path::Class::Dir->new(@$_) } @$_ ] };
+ from ArrayRef, via {
+ print "### in ArrayRef[Str] -> ArrayRef[$type] coercion\n";
+ [ map { Path::Class::Dir->new($_) } @$_ ] };
+# from ArrayRef[ArrayRef], via {
+# print "### in ArrayRef[ArrayRef] -> ArrayRef[$type] coercion\n";
+# [ map { Path::Class::Dir->new(@$_) } @$_ ] };
}
for my $type ( 'Path::Class::File', File ) {
from Str, via { Path::Class::File->new($_) },
from ArrayRef, via { Path::Class::File->new(@$_) };
- coerce ArrayRef[$type],
- from ArrayRef[Str], via { [ map { Path::Class::File->new($_) } @$_ ] },
- from ArrayRef[ArrayRef], via { [ map { Path::Class::File->new(@$_) } @$_ ] };
+# coerce ArrayRef[$type],
+# from ArrayRef[Str], via {
+# print "### in ArrayRef[Str] -> ArrayRef[$type] coercion\n";
+# [ map { Path::Class::File->new($_) } @$_ ] },
+# from ArrayRef[ArrayRef], via {
+# print "### in ArrayRef[ArrayRef] -> ArrayRef[$type] coercion\n";
+# [ map { Path::Class::File->new(@$_) } @$_ ] };
}
# optionally add Getopt option type
package Foo;
use Moose;
use MooseX::Types::Path::Class;
+ use MooseX::Types::Moose qw(ArrayRef);
has 'dir' => (
is => 'ro',
has 'dirs' => (
is => 'ro',
- isa => 'ArrayRef[Path::Class::Dir]',
+ isa => ArrayRef['Path::Class::Dir'],
coerce => 1,
);
has 'files' => (
is => 'ro',
- isa => 'ArrayRef[Path::Class::File]',
+ isa => ArrayRef['Path::Class::File'],
coerce => 1,
);
}
+__END__
+
+
+
my @dirs = (dir('', 'tmp'), dir('', 'etc'));
my @files = (dir('', 'tmp', 'foo'), dir('', 'etc', 'foo'));
# cmp_ok( ($o->files)->[$_], 'eq', "$files[$_]", "file is $files[$_]" ) foreach (0.. @files);
};
-for my $class (qw(Foo Bar)) {
+# XXX Foo omitted
+for my $class (qw(Bar)) {
my %args = (
dirs => [ map { "$_" } @dirs ],
-file => [ map { [ split('/', $_->stringify) ] } @files ],
+#file => [ map { [ split('/', $_->stringify) ] } @files ],
);
use Data::Dumper;
print "### constructing $class with args: ", Dumper(\%args);
$check_arrays->($o);
}
+
+
--- /dev/null
+use strict;
+use warnings;
+use MooseX::Types::Path::Class qw( Dir File );
+use MooseX::Types::Moose qw(ArrayRef);
+
+# just validate directly, without using a class:
+(ArrayRef[Dir])->assert_coerce(['/tmp', '/etc']);
+exit;