MooseX::Types::Path::Class - A Path::Class type library for Moose
package MyClass; use Moose; use MooseX::Types::Path::Class qw( Dir File ); with 'MooseX::Getopt'; # if you want the Getopt Role has 'dir' => ( is => 'ro', isa => Dir, required => 1, coerce => 1, ); has 'file' => ( is => 'ro', isa => File, required => 1, coerce => 1, ); # these attributes are coerced to the # appropriate Path::Class objects MyClass->new( dir => '/some/directory/', file => '/some/file' );
This module constructs coercions (see Moose::Util::TypeConstraints) from both 'Str' and 'ArrayRef' to both Path::Class::Dir and Path::Class::File objects. It also adds the Getopt option type ("=s") for both Path::Class::Dir and Path::Class::File (see MooseX::Getopt).
This is just meant to be a central place for these constructs, so you don't have to worry about whether they've been created or not, and you're not tempted to copy them into yet another class (like I was).
See MooseX::Types for how these exports work.
No bugs have been reported.
Copyright (c) 2007, Todd Hepler
<firstname.lastname@example.org>. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.