MouseX::Types3pm
Organize your mouse types in libraries
Usage
Library Definition
package MyLibrary;# predeclare our own typesuse MouseX::Types-declare => [qw(PositiveInt NegativeInt)];# import builtin typesuse 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 coercioncoerce PositiveInt,from Int,via { 1 };1;
Usage
package Foo;use Mouse;use MyLibrary qw( PositiveInt NegativeInt );# use the exported constants as type nameshas 'bar',isa => PositiveInt,is => 'rw';has 'baz',isa => NegativeInt,is => 'rw';sub quux {my ($self, $value);# test the valueprint "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;
Repository
git clone git://github.com/yappo/p5-mousex-types.git MouseX-Types
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.
Releases
7 releases since Debian 7 (Wheezy); the text changed 2 times.