MooseX::Types::Path::Class - A Path::Class type library for Moose



NAME

MooseX::Types::Path::Class - A Path::Class type library for Moose


VERSION

version 0.08


SYNOPSIS

  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' );


DESCRIPTION

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.


EXPORTS

None of these are exported by default. They are provided via the MooseX::Types manpage.

Dir, File
These exports can be used instead of the full class names. Example:
  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_Dir($value), is_File($value)
Returns true or false based on whether $value is a valid Dir or File.

to_Dir($value), to_File($value)
Attempts to coerce $value to a Dir or File. Returns the coerced value or false if the coercion failed.


SEE ALSO

the MooseX::Types::Path::Class::MoreCoercions manpage, the MooseX::FileAttribute manpage, the MooseX::Types::URI manpage


DEPENDENCIES

Moose, the MooseX::Types manpage, the Path::Class manpage


BUGS AND LIMITATIONS

If you find a bug please either email the author, or add the bug to cpan-RT http://rt.cpan.org.


AUTHOR

Todd Hepler <thepler@employees.org>


CONTRIBUTORS


COPYRIGHT AND LICENSE

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