NAME
MooX::Types::MooseLike - Moose like types for Moo
SYNOPSIS
package MyPackage;
use Moo;
use MooX::Types::MooseLike qw(:all);
has "beers_by_day_of_week" => (
isa => HashRef
);
has "current_BAC" => (
isa => Num
);
# Also supporting is_$type. For example, is_Int() can be used as follows
has 'legal_age' => (
is => 'ro',
isa => sub { die "$_[0] is not of legal age"
unless (is_Int($_[0]) && $_[0] > 17) },
);
SUBROUTINES (Types)
Any
Any type (test is always true)
Item
Synonymous with Any type
Undef
A type that is not defined
Defined
A type that is defined
Bool
A boolean 1|0 type
Value
A non-reference type
Ref
A reference type
Str
A non-reference type where a reference to it is a SCALAR
Num
A number type
Int
An integer type
ArrayRef
An ArrayRef (ARRAY) type
HashRef
A HashRef (HASH) type
CodeRef
A CodeRef (CODE) type
RegexpRef
A regular expression reference type
GlobRef
A glob reference type
FileHandle
A type that is either a builtin perl filehandle or an IO::Handle object
Object
A type that is an object (think blessed)
AHRef
An ArrayRef[HashRef] type
AUTHOR
Mateu Hunter hunter@missoula.org
THANKS
mst provided the implementation suggestion of using 'can' on a quoted sub to define a type (subroutine).
COPYRIGHT
Copyright 2011, Mateu Hunter
LICENSE
You may distribute this code under the same terms as Perl itself.