10 Jan 2013 21:24:10 UTC
- Distribution: MooseX-Types-Path-Class-MoreCoercions
- Module version: 0.003
- Source (raw)
- Browse (raw)
- How to Contribute
- Testers (742 / 0 / 0)
- KwaliteeBus factor: 1
- % Coverage
- License: apache_2_0
- Perl: v5.8.1
- Activity24 month
- Download (10.81KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version
- SEE ALSO
- COPYRIGHT AND LICENSE
MooseX::Types::Path::Class::MoreCoercions - More powerful coercion than MooseX::Types::Path::Class
### specification of type constraint with coercion package Foo; use Moose; use MooseX::Types::Path::Class::MoreCoercions qw/File AbsDir/; has filename => ( is => 'ro', isa => File, coerce => 1, ); has directory => ( is => 'ro', isa => AbsDir, coerce => 1, ); ### usage in code my $tmp = File::Temp->new; Foo->new( filename => $tmp ); # coerced to Path::Class::File Foo->new( directory => '.' ); # coerced to dir('.')->absolute
This module extends MooseX::Types::Path::Class with more powerful coercions, including:
coercing objects with overloaded stringification
coercing to absolute paths
This module uses MooseX::Types to define the following subtypes.
Diris a subtype of
MooseX::Types::Path::Class::Dir. Objects with overloaded stringification are coerced as strings if coercion is enabled.
AbsDiris a subtype of
Dir(above). Objects are also coerced to an absolute path.
Fileis a subtype of
MooseX::Types::Path::Class::File. Objects with overloaded stringification are coerced as strings if coercion is enabled.
AbsFileis a subtype of
File(above). Objects are also coerced to an absolute path.
Because an argument is stringified and then coerced into a Path::Class object, no reference to the original File::Temp argument is held. Be sure to hold an external reference to it to avoid immediate cleanup of the object at the end of the enclosing scope.
Please report any bugs or feature requests through the issue tracker at https://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-Types-Path-Class-MoreCoercions. You will be notified automatically of any progress on your issue.
This is open source software. The code repository is available for public review and contribution under the terms of the license.
git clone git://github.com/dagolden/moosex-types-path-class-morecoercions.git
David Golden <firstname.lastname@example.org>
This software is Copyright (c) 2012 by David Golden.
This is free software, licensed under:
The Apache License, Version 2.0, January 2004
Module Install Instructions
To install MooseX::Types::Path::Class::MoreCoercions, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install MooseX::Types::Path::Class::MoreCoercions
For more information on module installation, please visit the detailed CPAN module installation guide.