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
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.
Constructor. Accepts the following keys:
Clone the current typemap with additional
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.
Will return the
$type resolves to, or an undefined value if no matching entry is found.
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.