Smart::Dispatch::Table - a dispatch table
Smart::Dispatch::Table is a Moose class. (Well, Moo actually, but close enough.)
new(%attributes)
Create a new dispatch table.
make_combined($table1, $table2, ...)
Combine existing tables into a new one.
match_list
is 'rw', isa 'ArrayRef[Smart::Dispatch::Match]'.
exists($value, $include_failovers)
Searches for a Smart::Dispatch::Match that matches $value. Ignores failover matches, unless optional argument $include_failovers is true. Returns Smart::Dispatch::Match if it finds a match; returns nothing otherwise.
$value
$include_failovers
TL;DR: checks if value $value can be dispatched.
action($value, @additional)
Calls exists with $include_failovers set to true, then, if there is a result, calls conduct_dispatch($value, @additional) on that result.
exists
conduct_dispatch($value, @additional)
TL;DR: dispatches value $value.
conditional_matches
Returns a list of conditional matches. (Smart::Dispatch::Match objects.)
unconditional_matches
Returns a list of unconditional matches. (Smart::Dispatch::Match objects.)
Should only ever be zero or one items in the list.
all_matches
Returns the list which is the union of the above two lists.
append(@things)
Each thing must be a Smart::Dispatch::Table or a Smart::Dispatch::Match.
Handles conflicts between unconditional matches automatically.
prepend(@things)
validate_match_list
Checks that match_list looks OK (a maximum of unconditional match; checks that all conditional matches preceed unconditional matches).
This is done automatically after construction, prepending and appending, but if you've manipulated the match_list manually, it's good practice to all this method to check you've not broken it.
Smart::Dispatch::Table overloads various operations. (See overload.)
code derefernce &{} - funky stuff with action.
&{}
action
concatenation . - funky stuff with make_combined.
.
make_combined
addition + - funky stuff with make_combined.
+
concatenation assignment .= - append.
.=
append
addition assignment += - prepend.
+=
prepend
smart match ~~ - exists (with $ignore_failover false).
~~
$ignore_failover
Please report any bugs to http://rt.cpan.org/Dist/Display.html?Queue=Smart-Dispatch.
Smart::Dispatch.
Toby Inkster <tobyink@cpan.org>.
This software is copyright (c) 2012 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
To install Smart::Dispatch, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Smart::Dispatch
CPAN shell
perl -MCPAN -e shell install Smart::Dispatch
For more information on module installation, please visit the detailed CPAN module installation guide.