|
NAMEMooseX::Types::VariantTable - Type constraint based variant tableSYNOPSIS# see also MooseX::Types::VariantTable::Declare for a way to # declare variant table based methods use MooseX::Types::VariantTable; my $dispatch_table = MooseX::Types::VariantTable->new( variants => [ { type => "Foo", value => \&foo_handler }, { type => "Bar", value => \&bar_handler }, { type => "Item", value => \&fallback }, ], ); # look up the correct handler for $thingy based on the type constraints it passes my $entry = $dispatch_table->find_variant($thingy); # or use the 'dispatch' convenience method if the entries are code refs $dispatch_table->dispatch( $thingy, @args ); DESCRIPTIONThis object implements a simple dispatch table based on Moose type constraints.Subtypes will be checked before their parents, meaning that the order of the declaration does not matter. This object is used internally by Moose::Meta::Method::VariantTable and MooseX::Types::VariantTable::Declare to provide primitive multi sub support. ATTRIBUTESambigious_match_callbackA code reference that'll be executed when find_variant found more than one matching variant for a value. It defaults to something that simply croaks with an error message like this:Ambiguous match %s where %s contains a list of stringified types that matched. METHODS
TODOThe meta method composes in multiple inheritence but not yet with roles due to extensibility issues with the role application code.When Moose::Meta::Role can pluggably merge methods variant table methods can gain role composition. AUTHORYuval Kogman <nothingmuch@woobling.org>Florian Ragwitz <rafl@debian.org> COPYRIGHTCopyright (c) 2008 Yuval Kogman. All rights reserved This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Visit the GSP FreeBSD Man Page Interface. |