-
-
18 Oct 2011 02:06:52 UTC
- Distribution: MouseX-Types
- Module version: 0.06
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Repository
- Issues (4)
- Testers (8954 / 16 / 1)
- Kwalitee
Bus factor: 1- 94.77% Coverage
- License: perl_5
- Perl: v5.6.2
- Activity
24 month- Tools
- Download (29.43KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
and 1 contributors- Kazuhiro Osawa <yappo <at> shibuya <döt> pl>
- Dependencies
- Any::Moose
- Mouse
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
MouseX::Types - Organize your Mouse types in libraries
SYNOPSIS
Library Definition
package MyLibrary; # predeclare our own types use MouseX::Types -declare => [qw( PositiveInt NegativeInt )]; # import builtin types use MouseX::Types::Mouse 'Int'; # type definition. subtype PositiveInt, as Int, where { $_ > 0 }, message { "Int is not larger than 0" }; subtype NegativeInt, as Int, where { $_ < 0 }, message { "Int is not smaller than 0" }; # type coercion coerce PositiveInt, from Int, via { 1 }; 1;
Usage
package Foo; use Mouse; use MyLibrary qw( PositiveInt NegativeInt ); # use the exported constants as type names has 'bar', isa => PositiveInt, is => 'rw'; has 'baz', isa => NegativeInt, is => 'rw'; sub quux { my ($self, $value); # test the value print "positive\n" if is_PositiveInt($value); print "negative\n" if is_NegativeInt($value); # coerce the value, NegativeInt doesn't have a coercion # helper, since it didn't define any coercions. $value = to_PositiveInt($value) or die "Cannot coerce"; } 1;
AUTHORS
Kazuhiro Osawa <yappo <at> shibuya <döt> pl>
Shawn M Moore
tokuhirom
Goro Fuji
with plenty of code borrowed from MooseX::Types
REPOSITORY
git clone git://github.com/yappo/p5-mousex-types.git MouseX-Types
SEE ALSO
COPYRIGHT AND LICENSE
Copyright (c) 2008-2010, Kazuhiro Osawa and partly based on MooseX::Types, which is (c) Robert Sedlacek.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Module Install Instructions
To install MouseX::Types, copy and paste the appropriate command in to your terminal.
cpanm MouseX::Types
perl -MCPAN -e shell install MouseX::Types
For more information on module installation, please visit the detailed CPAN module installation guide.