MooseX::Types::Path::Class - A Path::Class type library for Moose |
MooseX::Types::Path::Class - A Path::Class type library for Moose
version 0.08
package MyClass; use Moose; use MooseX::Types::Path::Class; with 'MooseX::Getopt'; # optional
has 'dir' => ( is => 'ro', isa => 'Path::Class::Dir', required => 1, coerce => 1, );
has 'file' => ( is => 'ro', isa => 'Path::Class::File', required => 1, coerce => 1, );
# these attributes are coerced to the # appropriate Path::Class objects MyClass->new( dir => '/some/directory/', file => '/some/file' );
MooseX::Types::Path::Class creates common Moose types, coercions and option specifications useful for dealing with the Path::Class manpage objects as Moose attributes.
Coercions (see the Moose::Util::TypeConstraints manpage) are made
from both Str
and ArrayRef
to both the Path::Class::Dir manpage and
the Path::Class::File manpage objects. If you have the MooseX::Getopt manpage installed,
the Getopt
option type (``=s'') will be added for both
the Path::Class::Dir manpage and the Path::Class::File manpage.
None of these are exported by default. They are provided via the MooseX::Types manpage.
package MyClass; use Moose; use MooseX::Types::Path::Class qw(Dir File);
has 'dir' => ( is => 'ro', isa => Dir, required => 1, coerce => 1, );
has 'file' => ( is => 'ro', isa => File, required => 1, coerce => 1, );
Note that there are no quotes around Dir
or File
.
is_File($value)
Dir
or File
.
to_File($value)
Dir
or File
. Returns the coerced value
or false if the coercion failed.
the MooseX::Types::Path::Class::MoreCoercions manpage, the MooseX::FileAttribute manpage, the MooseX::Types::URI manpage
Moose, the MooseX::Types manpage, the Path::Class manpage
If you find a bug please either email the author, or add the bug to cpan-RT http://rt.cpan.org.
Todd Hepler <thepler@employees.org>
This software is copyright (c) 2007 by Todd Hepler.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
MooseX::Types::Path::Class - A Path::Class type library for Moose |