MooseX::TypeMap - A type-constraint-to-data map
use MooseX::Types::Moose qw(Str Int Num Value); my $map = MooseX::TypeMap->new( type_entries => [ MooseX::TypeMap::Entry->new( data => 'number', type_constraint => Num, ) ], subtype_entries => [ MooseX::TypeMap::Entry->new( data => 'string', type_constraint => Str, ) ] ); $map->resolve(Int); #returns 'string' $map->resolve(Num); #returns 'number' $map->resolve(Str); #returns 'string' $map->resolve(Value); #returns an undefined value
[]
An ArrayRef of Entry objects. These entry objects will only match on "resolve" when the type constraint given is equal to the type constraint in the entry.
An ArrayRef of Entry objects. These entry objects will match on "resolve" when the type constraint given is equal to, or a sub-type of, the type constraint in the entry.
A private attribute that mantains a sorted array of arrays of entries in the order in which they will be looked at if there is no matching entry in entries This attribute can not be set from the constructor, has no public methods and is only being documented for the benefit of future contributors.
entries
\%arguments
$object_instance
Constructor. Accepts the following keys: type_entries, subtype_entries.
type_entries
subtype_entries
Clone the current typemap with additional type_entries and subtype_entries and return the new instance which includes all the current entries and the additional ones provided. If \%arguments is ommitted, type map returned will be an identical clone of the invocant.
$type
Will return the $entry $type resolves to, or an undefined value if no matching entry is found.
$entry
Will return true if the given $type resolves to an entry and false otherwise.
Will find the closest matching entry for $type and return the contents of the entry's data attribute;
This software is copyright (c) 2008, 2009, 2010 by its authos as listed in the "AUTHORS" section.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
3 POD Errors
The following errors were encountered while parsing the POD:
Unknown directive: =items
To install MooseX::TypeMap, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MooseX::TypeMap
CPAN shell
perl -MCPAN -e shell install MooseX::TypeMap
For more information on module installation, please visit the detailed CPAN module installation guide.