MooseX...:Class(3pm)
β¨ NAME β¨
MooseX::Types::Path::Class β a Path::Class type library for Moose π
(also living its best life as MooseX...:Class(3pm) in the User Contributed Perl Documentation, iykyk)
πΈ VERSION πΈ
version 0.09 β yes bestie, that's the one
π¦ SYNOPSIS π¦
okay so here's the whole vibe, copy-paste ready:
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' );
likeβ¦ you hand it a plain string and it hands you back a whole Path::Class object. the glow-up is real ππ
π DESCRIPTION π
MooseX::Types::Path::Class creates common Moose types, coercions and option specifications that are, lowkey, extremely useful for dealing with Path::Class objects as Moose attributes. it's giving "I made your life easier and I didn't even ask for credit" π
So. The coercions (peep Moose::Util::TypeConstraints if you wanna know the mechanics) go from Str and from ArrayRef β both Path::Class::Dir and Path::Class::File objects. Two directions in, two types out, we love a flexible queen π
And β bonus round β if you have MooseX::Getopt installed, the Getopt option type (=s) gets added for both Path::Class::Dir and Path::Class::File. So your command line justβ¦ understands. iconic, no notes. β¨
π EXPORTS π
first things first: none of these are exported by default. they come to you via MooseX::Types. so don't be surprised when you don't get them for free, bestie π
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,
);
π¨ bestie listen to me: there are no quotes aroundDirorFile. it's a bareword situation. do not quote them. I'm begging π«Ά
is_Dir($value),is_File($value)β returns true or false depending on whether$valueis a validDirorFile. a little vibe check, if you will βto_Dir($value),to_File($value)β attempts to coerce$valueto aDiror aFile. gives you the coerced value back, or false if the coercion failed. no drama, just a falsy result π
π SEE ALSO π
go read these next, they're the friend group:
MooseX::Types::Path::Class::MoreCoercionsMooseX::FileAttributeMooseX::Types::URI
π§ DEPENDENCIES π§
the squad you need on deck: Moose, MooseX::Types, Path::Class.
π SUPPORT π
Got bugs? Same. π Send them through the RT bug tracker at <https://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-Types-Path-Class> β or, if email is your thing, bug-MooseX-Types-Path-Class@rt.cpan.org.
There's also a mailing list for users of this distribution, hanging out at <http://lists.perl.org/list/moose.html>. come vibe with us π
And there's an irc channel too, for users of this distribution, at #moose on irc.perl.org β that's <irc://irc.perl.org/#moose>. real ones know. π
π AUTHOR π
Todd Hepler <thepler@employees.org> β the original main character π
β¨ CONTRIBUTORS β¨
- Karen Etheridge
<ether@cpan.org> - Jonathan Rockway
<jon@jrock.us> - Yuval Kogman
<nothingmuch@woobling.org>
the way they all pulled up and made this betterβ¦ we stan π«Ά
π 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. so like, go forth and remix, responsibly πΈ
okay that's the whole page bestie, you're so welcome π β this was perl v5.34.0, dated 2022-06-30, MooseX...:Class(3pm), and I hope your paths are always coerced and your types always valid. mwah ππ
π¦ where this page comes from
- debian bookworm: libmoosex-types-path-class-perl 0.09-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libmoosex-types-path-class-perl 0.09-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libmoosex-types-path-class-perl 0.09-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libmoosex-types-path-class-perl 0.09-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libmoosex-types-path-class-perl 0.09-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms